I’m using ansible to install a cassandra cluster. Cassandra wants ip addresses and not hostnames in it’s config file. I need to get the ip address for each host. The problem is each physical server has multiple ip addresses associated with it. So I can’t just get the ip address using ansible_eth0[“ipv4”][“address”]. That will not be the correct ip address for the related host. The only var that has the correct ip I need is SSH_CONNECTION. But that is a string that has the source ip and port and the dest ip and port. The dest ip is the ip I need. Can I parse this string and get the ip I need or is there another way to get the ip address?
I also need to get the ip address for the first host and make it available for use in a template applied to the remaining hosts.