Hey guys I need to connect to my ec2 instances in various ways using the ec2.ini provided. Right now my I can only get my ec2.ini to connect to my instances via their private or public IP alone, but I need to connect to some instances via their private IP and some via their public. Any suggestions for introducing logic to accomplish this?
You can set destination_variable to public_dns_name in ec2.ini (I think this is the default). Amazon’s DNS servers resolve the public DNS name to the private IP when you’re inside AWS and to the public IP when you’re outside.
Does that help?
Unfortunately, this setting does not help. Perhaps I need to run Ansible from within Amazon instead of locally?
Can you elaborate on what doesn’t work vs what you want?
Sure!
Currently I run: " ansible all -m ping -i ec2.py "
With:
destination_variable = public_dns_name
You can try setting it to public_dns_name. It should resolve to the private IP when you’re inside the vpc, and to the public IP when your outside.