Given this playbook:
- hosts: localhost
vars:
mydict: { a: apple, b: banana }
myfruit: "{{ mydict[myletter] }}"
tasks:
- debug: msg="My fruit is {{ myvar }}"
when: myfruit is defined
When run with '--extra-vars myletter=a', in both 2.2.1.0 and 2.3.0.0, it says
"msg": "My fruit is apple"
When run with '--extra-vars myletter=c', in 2.2.1.0 it says
skipping: [localhost]
but in 2.3.1.0 it says
fatal: [localhost]: FAILED! => {"failed": true, "msg": "The conditional check 'myfruit is defined' failed. The error was: error while evaluating conditional (myfruit is defined): {{ mydict[myletter] }}: 'dict object' has no attribute u'c'\n\nThe error appears to have been in '/home/jsmift/ansible/dom/playbooks/foo.yml': line 9, column 7, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n# - debug: var=myfruit\n - debug: msg=\"My fruit is {{ myfruit }}\"\n ^ here\nWe could be wrong, but this one looks like it might be an issue with\nmissing quotes. Always quote template expression brackets when they\nstart a value. For instance:\n\n with_items:\n - {{ foo }}\n\nShould be written as:\n\n with_items:\n - \"{{ foo }}\"\n"}
instead.
It still seems to happen in devel (as of 'ansible 2.4.0 (devel 9bcc3f298f)').
Is this an intentional change, or a bug? I'm happy to file a bug report if
it's unexpected, but figured I'd check first if I was wrong to expect this
to work as it did in 2.2.
-Josh (jbs@care.com)
(apologies for the automatic corporate disclaimer that follows)
This email is intended for the person(s) to whom it is addressed and may contain information that is PRIVILEGED or CONFIDENTIAL. Any unauthorized use, distribution, copying, or disclosure by any person other than the addressee(s) is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email and delete the message and any attachments from your system.