Home condition template in ansible
Reply: 1

condition template in ansible

pyramid13
1#
pyramid13 Published in 2018-02-13 06:41:09Z

I have this template (set_ip.j2):

{% if '{{ansible_env.SSH_CONNECTION.split(' ')[2]}}' == '{{ ip_ssh }}' %}
   address = {{ ip_db }}
   name='db1'
{% endif %}

but this condition not work! I want address and name set by this value in the config file.

Konstantin Suvorov
2#
Konstantin Suvorov Reply to 2018-02-13 06:46:03Z

Never ever use nested expressions in Jinja2:

{% if ansible_env.SSH_CONNECTION.split(' ')[2] == ip_ssh %}
   address = {{ ip_db }}
   name='db1'
{% endif %}
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32196 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO