In my scripts I also use "or" expression... How would I do that? And what 
about the poor souls that want to use complex boolean expression?...

--
Arie

On Tuesday, March 4, 2014 2:49:44 PM UTC+2, Michael DeHaan wrote:
>
> The following tricks are available:
>
> ---
> - hosts: all
>
>   vars:
>     x: 1
>     y: 2
>     alpha: x > 2
>     beta:  y > 3
>
>   tasks:
>
>     - shell: echo hi 1
>       when: alpha
>
>     - shell: echo hi 2
>       when:
>         - alpha
>         - beta
>
> Note that 'when: "alpha and beta"' is ambigious to the system, and won't 
> do what you want, because it has a hard time understanding whether a 
> variable is a variable expression or a string or not.
>
>
>
>
> On Tue, Mar 4, 2014 at 7:11 AM, Arie Skliarouk <[email protected]<javascript:>
> > wrote:
>
>> Hi,
>>
>> I am migrating ansible from 0.9 to 1.5 and complex when condition don't 
>> work anymore:
>>
>>   vars:
>>     not_main: "'$c_main' == 'no'"
>>     is_main: "'$c_main' == 'yes'"
>>     not_lxc: "'$lxc' != 'yes'"
>>
>>   tasks:
>>   # This does not work properly, it is always being applied
>>   - name: test0.conf
>>     action: template src=/tmp/test.conf.j2 dest=/tmp/test0.conf owner=ops 
>> group=ops mode=0444
>>     when: not_main and not_lxc
>>  # This works but prints warnings about using ${foo} or $foo. This is 
>> what I used in the past with ansible 0.9 (with only_if).
>>   - name: test1.conf
>>     action: template src=/opt/opsfs/tmp/test.conf.j2 dest=/tmp/test1.conf 
>> owner=ops group=ops mode=0444
>>     when: $not_main and $not_lxc
>> # This works but is longer to type and not as readable as the first 
>> example
>>   - name: test2.conf
>>     action: template src=/opt/opsfs/tmp/test.conf.j2 dest=/tmp/test2.conf 
>> owner=ops group=ops mode=0444
>>     when: c_main == 'no' and lxc != 'yes'
>>
>> What is the correct way to use complex when conditions?
>>
>> --
>> Arie
>>
>> -- 
>> 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/8d870518-5473-4e44-826c-f6674d1fc306%40googlegroups.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 [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/0f7f4886-4abe-4a15-bc67-ec7f691e1f60%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to