$ ansible --version
ansible 1.8 (develop 0179c13e04) last updated 2014/10/24 11:53:25 (GMT -700)
Right now I’m using “-i inventories/ec2.py -l 'tag_Environment_” to apply playbooks to servers in an environment, by IP address.
Now I have playbooks to stop and start all instances in an environment, but haven’t found a way to use ec2.py to apply these playbooks to all servers in the environment because stop and start needs a list of instance IDs rather than IP addresses. Is there a way? I’m thinking not, because ec2.py I don’t see instance_id in the list of variables returned when run against a specific host.
If not, my intent is to write a script to use the cli to generate/regenerate a list of instance IDs for the instance_ids variable.
Thanks for any help,
Paul
[...]
Right now I'm using "-i inventories/ec2.py -l
'tag_Environment_<environment>" to apply playbooks to servers in an
environment, by IP address.
Now I have playbooks to stop and start all instances in an environment, but
haven't found a way to use ec2.py to apply these playbooks to all servers
in the environment because stop and start needs a list of instance IDs
rather than IP addresses. Is there a way?
I'm not an export, but please check the ec2_id variable. I think it's
what you look for.
Cheers,
Wawrzek
Thanks, Wawrzek,
Also I’m seeing this in ec2.py. Makes me hopeful. Newb to Ansible and python so will take me a little while to figure out.
https://raw.githubusercontent.com/ansible/ansible/devel/plugins/inventory/ec2.py
def __init__(self):
''' Main execution path '''
# Inventory grouped by instance IDs, tags, security groups, regions,
# and availability zones
self.inventory = self._empty_inventory()
# Index of hostname (address) to instance ID
self.index = {}
Paul