Hello,
Still the warning "It is unnecessary to use '{{' in conditionals".
I have read old posts on this subject and the ticket 
https://github.com/ansible/ansible/issues/4582
I am using latest devel release.
But I don't understand why I get this message and if I am using the good 
way of doing what I want.
I have to make a lot of tasks under certain conditions.
In order to simplify, I do something like this;

- shell: something
  register st
- set_fact: flag=0
- set_fact: flag=1
  when: cur_sw.stdout == "something'
- shell: something else
  when: flag==1
...

So, I use a fact as a boolean flag to skip or not following tasks.
If flag==1, I execute the following tasks and then update again flag 
according to the result.
And if still 1, I execute some other tasks.

My problem is that when I do:
  when: flag==1
it does not work: it always skip the task.
In order to have it to work, I have to do:
  when: "{{flag}}==1"
But when I do that, I have the warning:
  It is unnecessary to use '{{' in conditionals, leave variables in loop 
expressions bare.
I can avoid the warning by doing:
  when: "1=={{flag}}"
but it is only a poor trick!

Please, could you explain me why 
  when: flag==1
does not work?

Thanks for your help!




-- 
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/55b02402-0d36-44b7-9ec6-2c2554a3e44c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to