Filtering on a Template variable

12 views
Skip to first unread message

Anfield

unread,
Aug 24, 2017, 11:08:57 PM8/24/17
to Ansible Project
How can I filter a variable in a template so that I can extract a fact

Trying to get the default ipv4 address from a template

template.j2
ipv4 address ((ansible_default_ipv4 | grep address}}

A similar format will work via command line but not via a template. Whats the correct formatting required to do something like that via template?

Thanks

Dick Visser

unread,
Aug 25, 2017, 3:20:34 AM8/25/17
to ansible...@googlegroups.com
ipv4 address {{ ansible_default_ipv4.address }}
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/05c67110-b81c-4bd0-bd3a-04007f24697c%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Dick Visser
GÉANT

Want to join us? We're hiring: https://www.geant.org/jobs

Anfield

unread,
Aug 25, 2017, 3:50:38 PM8/25/17
to Ansible Project
That works thanks. I suppose what confused me a little was when trying to do this via command line I had to use grep..

[ansible@localhost exercises]$ ansible local -m setup -a 'filter=ansible_default_ipv4*' | grep address


Reply all
Reply to author
Forward
0 new messages