Hi everyone,
one simple question and sry for my english skills :-)
I have a playbook with some templates, in one template I added a condition to write a specific IP Address in my template.
(My servers have several network ports and unfortunately they have sometimes different names. Ok, i could use different templates but i wanted to use a single file)
The code:
{% if ansible_mgt.ipv4.address is defined %}
server_address={{ansible_mgt.ipv4.address}}
{% else %}
server_address={{ansible_eth0.ipv4.address}}
{% endif %}
If I run the playbook against a server which has not the network port ansible_mgt the playbook fails because the variable ansible_mgt.ipv4.address is not defined.
What I am doing wrong? Or it is not possible to check in a template if a variable is not defined?
Thanks for your help!
Regards,
Jost