replace public ip from /etc/hosts file with private ip using Ansible

27 views
Skip to first unread message

BB

unread,
Aug 29, 2016, 10:24:36 AM8/29/16
to Ansible Project, Biswajit Banerjee
I need to replace public ip from /etc/hosts file with private ip in bulk cluster of systems.
Ansible gathered fact , may work but not sure which is for what.

Another way, I can have public and private ip register as variable and swap them.

What would be the best practice to do in ansible way?

Currently in /etc/hosts 
________
public_ip   hostname short_hostname

I need to change it to 

private_ip  hostname short_hostname



BB

unread,
Aug 29, 2016, 10:24:57 AM8/29/16
to Ansible Project

ZillaYT

unread,
Aug 29, 2016, 2:02:15 PM8/29/16
to Ansible Project, biswajit....@gmail.com
Look at the "lineinfile" module.
Reply all
Reply to author
Forward
0 new messages