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] <javascript:>> 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/ae961073-8103-4ea5-951f-cc44e1e7a6b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.