Sorry, "Unfortunately, shutdown didn't work..." should read "Unfortunately, starting 'stopped' instances didn't work...".
On Monday, March 10, 2014 2:19:54 PM UTC-7, [email protected] wrote: > > Ah, thank you very much, this indeed allowed me to shut down all > instances in an environment (code pasted below if anyone ever needs to > google this). Unfortunately, shutdown didn't work because ec2.py doesn't > seem to list stopped instances (even after --refresh-cache). > > Thank you both. > > > -------------------------------- sample below > --- > - hosts: localhost > gather_facts: false > connection: local > tasks: > - name: Stop the instances for pod '{{pod}}' > local_action: > module: ec2 > instance_ids: "{{hostvars[item]['ec2_id']}}" > state: stopped > region: 'us-west-1' > wait: false > with_items: "groups.tag_env_{{pod}}" > --------------------------------- sample end > > > On Monday, March 10, 2014 10:46:15 AM UTC-7, Michael DeHaan wrote: >> >> >> >> On Mon, Mar 10, 2014 at 1:22 PM, <[email protected]> wrote: >> >>> Just trying to understand: what is your proposed solution for, say >>> 'starting all EC2 VMs that match tag_env_prod in zone US-WEST-1'? >>> >> >> You can iterate over hosts and check states like so: >> >> - hosts: localhost >> tasks: >> >> - shell: blah >> when: hostvars[item][ec2_state] == blah and item in >> hostvars[item]['ec2_region'] == blah >> with_items: groups.tag_env_prod >> >> >> The region should also be available as a group: >> >> when: item in groups.foo >> >> etc >> >> >> -- 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/1098a1f5-2d75-4f1b-a306-7058164b054d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
