Ansible/jinja2: Use filter result in if condition


is it possible to use the result of Jinja2 filters in conditions in ansible playbooks?

I’m trying to get this working, but without success:

where item in my current test is set to localhost (and could be any other private or public domain).

Should do: If item is an IPv4 address the adress should be returned, otherwise it should be “converted” (DNS lookup with dig) to an IPv4 address – but it always is returning the hostname.

Any idea?

Thanks in advance



Leave a Reply