Running ansible 1.9.1. Maybe the booloean section in https://docs.ansible.com/playbooks_conditionals.html#the-when-statement nees to reflect this and spent some time to figure this out?
Cheers, Si. On Tuesday, June 23, 2015 at 6:56:16 PM UTC+1, Michael Peters wrote: > > This bug should be fixed. Which version are you using? But even when > it's fixed, the string "false" is a true value. > > I do admit that "|bool" everywhere is kind of annoying, but it's the > safest way to always make sure your context is correct. > > On Tue, Jun 23, 2015 at 12:31 PM, Si W <[email protected] <javascript:>> > wrote: > > > > > > I have been struggling with booloean handling and read through > > https://github.com/ansible/ansible/issues/8629 not sure if its fixed or > I am > > just not getting the jist. If I run something like .. > > > > > > > > > > > > vars: > > foo: True > > bar: False > > foobar: '{{ foo and bar }}' > > > > tasks: > > > > - debug: msg="If foo is True" > > when: foo > > > > - debug: msg="If bar is False" > > when: not bar > > > > - debug: msg="foobar is True" > > when: foobar > > > > - debug: msg="foobar is false" > > when: not foobar > > > > - debug: msg="foobar|bool is false" > > when: not foobar|bool > > > > - debug: > > var=foobar > > > > If I run the above I get > > > > PLAY [localhost] > > ************************************************************** > > > > > > TASK: [debug msg="If foo is True"] > > ******************************************** > > ok: [localhost] => { > > "msg": "If foo is True" > > } > > > > TASK: [debug msg="If bar is False"] > > ******************************************* > > ok: [localhost] => { > > "msg": "If bar is False" > > } > > > > TASK: [debug msg="foobar is True"] > > ******************************************** > > skipping: [localhost] > > > > TASK: [debug msg="foobar is false"] > > ******************************************* > > skipping: [localhost] > > > > TASK: [debug msg="foobar|bool is false"] > > ************************************** > > ok: [localhost] => { > > "msg": "foobar|bool is false" > > } > > > > TASK: [debug var=foobar] > > ****************************************************** > > ok: [localhost] => { > > "var": { > > "foobar": "False" > > } > > } > > > > PLAY RECAP > > ******************************************************************** > > localhost : ok=5 changed=0 unreachable=0 > failed=0 > > > > > > Is this just expected behaviour due to mix of yaml and jinja2 it just > seems > > messy having to work out when to use |bool ? > > > > Cheers > > Si > > > > > > > > > > -- > > You received this message because you are subscribed to the Google > Groups > > "Ansible Project" group. > > To unsubscribe from this group and stop receiving emails from it, send > an > > email to [email protected] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/ansible-project/c6224986-e2c0-4cb0-9ce1-3c870d0ccd6e%40googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/6059f6d8-b018-467f-85a9-d3febdd980f9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
