On 19.02.2019 17:07, Pandu jh wrote:
> If possible could you please explain the syntax, It will be very
> helpful
> for me to use it in other cases.
I could try, not sure if it's understandable
Just split it in multiple lines
[1] {{ host_fqdn
[2] if '
lab.com' in host_fqdn
[3] else
[4] host_fqdn ~ '.
lab.com' }}
[2]
If the variable host_fqdn contains the string
lab.com the choose [1].
[3]
If the variable host_fqdn dosen't contains the string
lab.com the choose
[4]
[4]
Tilde is used to concatenate two strings.
So this will concatenate the content of variable fqdn_host with the
string .
lab.com
You can also use the Ansible ternary filter
{{ ('
lab.com' in host_fqdn) | ternary(host_fqdn, host_fqdn ~ '.
lab.com')
}}
--
Kai Stian Olstad