Instead of modifying ec2_facts, perhaps you want to modify the ec2 dynamic inventory plugin to return the information you need?
-Toshio On Tue, Nov 18, 2014 at 8:28 AM, Matthew Morgan <[email protected]> wrote: > Hello, > > I've run into a situation where I need to define a variable of EC2 public > IPs so I can pass them into my cassandra nodes as seeds. > > The problem being, I don't know a good way to get the public IPs. I > currently use static inventory (blank, just for groups) and dynamic > inventory (ec2.py). > > So Ideally, I'd be able to do something like > > cassandra_seeds: "{{ > hostvars[groups['tag_service_az_cassandra-a'][ansible_ec2_public_ipv4] }}" > > however, this doesn't work. 'ansible_ec2_public_ipv4' is only present when > ec2_facts has been run. ec2_facts can only be run on the instance ansible > is currently provisioning and I need the cassandra_seeds variable across all > my cassandra instances. > > Another idea was: > > cassandra_seeds: "{% for host in groups['tag_service_az_cassandra-a'] %} > {{hostvars[host].ansible_ec2_public_ipv4 }} {% end for %}" > > Again, this falls apart because ansible_ec2_public_ipv4 isn't present. None > of the ansible_ facts gathered have the public ip, only ec2_facts has it. > > I realize I could change ec2.ini to return public ip for vpc instances, but > that would break all of my other plays... I need private ips everywhere > else, this is the only instance where I need to use public ips. > > The only potential solution I have figured out would be to write a record to > route53 for this express purpose of recording the public ip, but that seems > like a failure on using ansible correctly. > > This seems like it should be really easy, What am I missing? > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/461fd936-e20b-439f-8b26-11c29d0c99d6%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAG9juEq3xn864s3agpQYwjX9nG-8YppvNFZLBQF2wBzJ5vO%3DMQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
