Hi Team. I want to obtain internal IP of my machine using ansible. How can I ach . . .

Karthik:
Hi Team. I want to obtain internal IP of my machine using ansible. How can I achieve it?

Mohamed Ayman:
Hello @Karthik
You can use
ansible_default_ipv4.address fact

Karthik:
This will also generate the external IP I guess? @Mohamed Ayman

Mohamed Ayman:
Do you mean the ip of the target server ? if yes, so it’s correct

Karthik:
Yeah I saw that. But I need the internal IP of the target server

Mohamed Ayman:
Try this fact

ansible_all_ipv4_addresses

you will get all addresses of the server, and you can pass it to the ipaddr filter.

{{ ansible_all_ipv4_addresses | ipaddr('private') | first }}