TASK: [everything for that one host] ******************************************
ok: [127.0.0.1] => {
“hostvars["54.171.160.194"]["ec2_id"]”: “i-f28793b0”
}
The problem is that in order to stop and ec2 instances, I need to get at the ec2_id, in order to feed it to the ec2 module (which stops nodes based upon the instance id, not the ip address.
tasks:
name: shut down all the spot instances
local_action:
module: ec2
region: eu-west-1
wait: no
instance_ids: ‘{{ instance_ids }}’
state: absent
I can’t figure out how to munge this into a usable list, has anyone else experienced this before?
This is how I got something similar working in order to terminate instances. You will need to change the state and I’m using the inventory script as my hosts file. I’m sure it can be cleaned up. In this case, I’m targeting ec2 instances with the Nginx_Server tag.