Hi, 

I am not sure if this problem is solved already, however, I recently 
implemented a python shell script to retrieve the instance_ids.

conn = boto.ec2.connect_to_region(region, aws_access_key_id=
aws_access_key_id, aws_secret_access_key=aws_secret_access_key)

instances=conn.get_only_instances(filters={'tag:tag_name':[tag_value]})

instance_ids = []
for instance in instances:
   instance_ids.append(instances[0].id)

print json.dumps(instance_ids)


This script allows you to retrieve the instance_ids even if the instances 
have been stopped.  


On Friday, 7 March 2014 09:43:31 UTC-8, [email protected] wrote:
>
> Hey all,
>
> I'm trying to use the EC2 module to start/stop instances, but I don't have 
> the specific IDs ahead of time.  I've been trying to get it to run one task 
> to grab the IDs from the EC2 inventory, and one to actually run the command 
> on localhost, but I can't seem to find a way to match both.  I either get 
> "no hosts match" (when I use a [local] inventory) or I cannot find 
> localhost when using the ec2 inventory.
>
> Is there an example anywhere of collecting ec2 instance ids and reusing 
> them?
>

-- 
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/26b87060-05e7-4110-8f2c-b01906ff16a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to