Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a variable list for tags parameter results in an unhashable type: 'list' exception #49825

Closed
cnunemaker opened this issue Dec 12, 2018 · 1 comment · Fixed by #49833
Closed
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.

Comments

@cnunemaker
Copy link

SUMMARY

Providing a variable list to the tags parameter results in the following error message:

ERROR! Unexpected Exception, this is probably a bug: unhashable type: 'list'
ISSUE TYPE
  • Bug Report
COMPONENT NAME

Tags parameter

ANSIBLE VERSION
ansible 2.7.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
CONFIGURATION
Nothing changed from defaults.
OS / ENVIRONMENT

Red Hat Enterprise Linux Server release 7.5 (Maipo)

STEPS TO REPRODUCE

Run with ansible-playbook -vvvv foo.yml.

- hosts: all
  remote_user: root
  gather_facts: no
  vars:
    foo: ['foo', 'bar']
  tasks:
  - debug:
      msg: "{{ foo }}"
    tags: "{{ foo }}"
EXPECTED RESULTS

Expect no error/exception.

ACTUAL RESULTS
ansible-playbook 2.7.4
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.5 (default, May 31 2018, 09:41:32) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /etc/ansible/ansible.cfg as config file
setting up inventory plugins
/etc/ansible/hosts did not meet host_list requirements, check plugin documentation if this is unexpected
/etc/ansible/hosts did not meet script requirements, check plugin documentation if this is unexpected
Set default localhost to localhost
Parsed /etc/ansible/hosts inventory source with ini plugin
Loading callback plugin default of type stdout, v2.0 from /usr/lib/python2.7/site-packages/ansible/plugins/callback/default.pyc

PLAYBOOK: foo.yml ***************************************************************************************************************************************************************************************************************************
1 plays in foo.yml

PLAY [all] **********************************************************************************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: unhashable type: 'list'
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 118, in <module>
    exit_code = cli.run()
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 122, in run
    results = pbex.run()
  File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 156, in run
    result = self._tqm.run(play=play)
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 263, in run
    start_at_done=self._start_at_done,
  File "/usr/lib/python2.7/site-packages/ansible/executor/play_iterator.py", line 197, in __init__
    new_block = block.filter_tagged_tasks(play_context, all_vars)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/block.py", line 394, in filter_tagged_tasks
    return evaluate_block(self)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/block.py", line 389, in evaluate_block
    new_block.block = evaluate_and_append_task(block.block)
  File "/usr/lib/python2.7/site-packages/ansible/playbook/block.py", line 383, in evaluate_and_append_task
    task.evaluate_tags(play_context.only_tags, play_context.skip_tags, all_vars=all_vars)):
  File "/usr/lib/python2.7/site-packages/ansible/playbook/taggable.py", line 63, in evaluate_tags
    tags = set([i for i, _ in itertools.groupby(tags)])
TypeError: unhashable type: 'list'
@ansibot
Copy link
Contributor

ansibot commented Dec 12, 2018

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback. labels Dec 12, 2018
sivel added a commit to sivel/ansible that referenced this issue Dec 12, 2018
@sivel sivel removed the needs_triage Needs a first human triage before being processed. label Dec 17, 2018
kbreit pushed a commit to kbreit/ansible that referenced this issue Jan 11, 2019
* Allow tags to be templated from a variable. Fixes ansible#49825

* Restore _load_tags to ensure we do csv tag splitting

* Add tests for csv tags and templated tags

* evaluate_tags doesn't need to accept strings, because _load_tags handles this
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. support:core This issue/PR relates to code supported by the Ansible Engineering Team. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants