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
Bug Report: Trying to resolve a dictionary key from an empty list #10920
Comments
@bcoca skiping task is correct behaviour for empy iterator? |
@mightydok yes, with_ should skip if given None/Empty list |
In the current devel branch, an empty list does result in a skipped task: # ansible-playbook -vv 10920.yml -e elasticsearch_plugins=[] Using /etc/ansible/ansible.cfg as config file 1 plays in 10920.yml PLAY: *************************************************************************** TASK [iterate over an non-existent variable] ************************************ ok: [localhost] => {"changed": false, "results": [], "skipped": true, "skipped_reason": "No items in the list"} PLAY RECAP ********************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=0 Dealing with a non-existent variable is a bit more complex, since we have traditionally allowed bare-variables in Per our normal policy, we close bug report issues when we see the issue has been corrected in the devel branch, so we will close this issue now. If you continue seeing any problems related to this issue, or if you have any further questions, please let us know by stopping by one of the two mailing lists, as appropriate:
Because this project is very active, we're unlikely to see comments made on closed tickets, but the mailing list is a great way to ask questions, or post if you don't think this particular issue is resolved. Thank you! |
@jimi-c thanks! I'm not 100% familiar with the development process, but what sort of time period are we talking about for going from current |
@Rylon we're looking at releasing an official 2.0 beta in early August. Major releases are generally done every three months, however we're going a bit slower with 2.0 as it is a fairly major change. |
@jimi-c Sounds great, thanks :) |
Issue Type
Bug Report
Ansible Version
ansible 1.9.1
configured module search path = None
Environment
Running from Mac OS X 10.10.3, managing Ubuntu 14.04 LTS.
Summary
Using
with_items
and an empty list, the task fails if the list is expected to contain dictionaries, which you try to lookup by key.Steps To Reproduce
Consider this task:
When the
elasticsearch_plugins
variable is not defined, or is defined as an empty list ([]
), I would expect the entire task to be skipped, however it looks like maybe Ansible is still trying to lookup thename
key fromitem
, which won't exist if the list is empty, and this results in the following failure:fatal: [ubuntu_trusty] => One or more undefined variables: 'unicode object' has no attribute 'name'
When
elasticsearch_plugins
is defined as follows, this task works normally:Expected Results
When the
elasticsearch_plugins
variable is an empty list, this task should be skipped, without attempting to lookupitem.name
oritem.installs_to
.Actual Results
The task fails, with the following error:
fatal: [ubuntu_trusty] => One or more undefined variables: 'unicode object' has no attribute 'name'
The text was updated successfully, but these errors were encountered: