Am Freitag, 26. Mai 2017 18:12:43 UTC+2 schrieb Kai Stian Olstad:
>
> On 26. mai 2017 14:54, Jörg Kastning wrote: 
> > I found this discussion in the githup issue mentined above. In my case I 
> > need to run a play only when a certain string was found an the output of 
> > another command. Example main.yml from one of my roles: 
> > --- 
> >    - name: Install Red Hat Security Advisory (RHSA) 
> >      command: yum -y update-minimal --advisory {{ rhsa_to_install }} 
> >      register: yum_output 
> >    - debug: var=yum_output 
> > 
> >    - name: Reboot Host if any packages were updated 
> >      shell: sleep 2 && shutdown -r now "Ansible updates triggered" 
> >      async: 1 
> >      poll: 0 
> >      ignore_errors: true 
> >      when: ("Complete!" in "{{ yum_output.stdout_lines[-1] }}") or 
> >            ("Komplett!" in "{{ yum_output.stdout_lines[-1] }}") 
> > 
> >   Since Ansible 2.3 I got the warnings described in detail in 
> > https://github.com/ansible/ansible/issues/22397. 
> > 
> > I would like to get back the behaviour from Ansible <2.3. While I'm new 
> to 
> > Ansible I may simply not know how to work around this warnings by 
> declaring 
> > the when statement in a different way. Could someone give me a hand 
> here? 
>
> In your case you need to do what the warning says, remove the "{{ and 
> the }}" and the warning will be gone. 
>
>    when: ("Complete!" in yum_output.stdout_lines[-1]) or 
>          ("Komplett!" in yum_output.stdout_lines[-1]) 
>

Thanks for helping me Kai. I appreciate it.

This change took me by surprise and I'm lucky that I only have a few roles 
to change. IMHO it was easier to read with the curly braces, because you 
could see at the first look that there is a variable substitution taking 
place.

Brian wrote:

> There are just 2 contexts, normal (you require them) and conditionals 
> (anything with when:) which don't. It is consistent, juts not uniform.


I do not understand the need for two different contexts here? Why could it 
not kept the way like it was in Ansible <2.3.

Thanks,
Joerg 

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to