replacing public ip with private in /etc/hosts

I am trying to replace public ip with private ip in /etc/hosts for bulk of hosts .

Current setup

PUBLIC_IP hostname shot_hostname

Needed :

PRIVATE _IP hostname short_hostname

How I can do it using ansible? I wonder if it can be done using gathered facts by ansible?
I would think of , getting the public ip and register as variable and same time get the private ip .
Now, replacing it using replace or inline module. Any best approach ?