How to get host private network address in Ansible

Question:

I’ve tried something like this:

It works, but I have problem with servers where I use docker, ’cause docker containers also have interface adress started with 10.x.x.x.

So, how can I get host private network address?

Answer:

You could use ansible_all_ip_addresses fact and the ipaddr filter.

Note: You can check what ansible facts you have available with ansible -m setup localhost

Edit: You can also filter by ip using ipaddr

Leave a Reply