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].
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/8d870518-5473-4e44-826c-f6674d1fc306%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to