Hi All,

Am new to this group and Google Groups in general so please go easy.

I have a few questions about the recent change in Ansible 2.3.0.0 that new 
prints a warning when jinja2 templating is included in a when, changed_when 
and failed_when statement. Please see this closed GitHub issue for more 
details on exactly what warning I mean: 
https://github.com/ansible/ansible/issues/22397

We have some very complex plays that depend on multiple roles. The roles 
are kept very generic by design so they can be used by multiple calling 
roles. Example: we may have plays for three or four completely different 
Java web apps that all depend on a common Tomcat role, passing in 
overriding variables for customisation.

This now causes any when statement that uses one of these overridden 
variables to throw a warning. Please find a very simplistic example below:

*Parent Role - defaults*
bootstrap_ping : true

*Parent Role - meta*
dependencies:

  - { role: apollo/platform/ping, ping: '{{ bootstrap_ping }}' }

*Child Role - tasks*
- name: execute

  when: ping

  win_ping:

This throws the warning.

I have looked at a few GitHub threads and a few Stack Overflow questions 
and have yet to see a valid workaround for this situation.

I also do not understand why Ansible processes Jinja2 under when statements 
if the stance is you are not supposed to do it. I raised a PR (here: 
https://github.com/ansible/ansible/pull/24974) which was swiftly closed 
(fair enough, I have never contributed to this project before and I did not 
follow procedure).

I was hoping someone could please help with the below questions to educate 
myself and improve our Ansible playbooks further:


   1. Will this remain forevermore just a warning or will it become a hard, 
   breaking error in a future release?
   2. What is the 'proper' way to write the above example whilst keeping 
   things modular?
   3. If this will remain just as a warning what about the possibility of 
   implementing an ansible.cfg flag to turn it off?

Really appreciate any help,
Thanks!
Rich

-- 
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