Lets suppose we have the following code sample:
- name: Bug report
hosts: localhost
gather_facts: no
connection: local
vars:
foo: no
bar: "{{ foo }}"
tasks:
- debug: msg='This should not be skipped!'
when: not bar
Seeing the code one would expect that the message "This should not be skipped" is displayed when the code is executed. In reality, however, the code gets skipped because the bar parameter is not correctly resolved to its value no. Rewriting the when clause to look like this:
seems to fix the problem.
Also it seems that this problem is only caused when the not operator is used, because if I use the following code sample:
- name: Bug report
hosts: localhost
gather_facts: no
connection: local
vars:
foo: yes
bar: "{{ foo }}"
tasks:
- debug: msg='This should not be skipped!'
when: bar
everything seems to work as expected.
So is this a bug (perhaps a known issue) or am I doing something wrong?