Hi Jesse,

Thanks for getting to the bottom of this and providing a working solution!
Works as charm indeed! Jinja framework is crazy IMHO.

Adam: grouping does not help, I tried it before submitting my first
request, as well as swapping the order.

The issue is solved, thank you! I wonder what is the process of altering
documentation on docs.ansible.com, googling for it provided me a link which
does not contain the text that is shown in the search preview.
Does submitting an issue to the Ansible
repo<https://github.com/ansible/ansible> sound
like a proper idea?



On Tue, Feb 4, 2014 at 1:17 PM, Jesse Keating <jkeat...@j2solutions.net>wrote:

> On 2/3/14, 4:32 PM, Roman Revyakin wrote:
>
>> cat > test_playbook.yaml <<EOF
>> ---
>> - hosts: all
>>    gather_facts: false
>>
>>    tasks:
>>      - name: Play only if var1 is true and var2 is defined
>>        local_action: command echo "Yes {{ var1 }} is true and {{ var2 }}
>> is defined"
>>        when: var1 and var2 is defined
>> EOF
>>
>> $ ansible-playbook -i host -v test_playbook.yaml --extra-vars
>> "var1=false var2='something'"
>>
>> PLAY [all]
>> ********************************************************************
>>
>> TASK: [Play only if var1 is true and var2 is defined]
>> *************************
>> changed: [localhost] => {"changed": true, "cmd": ["echo", "Yes false is
>> true and something is defined"], "delta": "0:00:00.003256", "end":
>> "2014-02-04 11:19:56.720699", "rc": 0, "start": "2014-02-04
>> 11:19:56.717443", "stderr": "", "stdout": "Yes false is true and
>> something is defined"}
>>
>
> You most certainly have a string to bool comparison issue going on.
>
> You can change this by using the bool filter.
>
> when: var1|bool and var2 is defined
>
> When I use this, var1 being "false" will still cause the task to be
> skipped as expected.
>
>
> -jlk
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/ansible-project/YPfK1KYpQeI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to