Apologies in advance here: I'm missing something fundamental.
I'm trying to do something pretty simple: I'm putting new code into a QA
environment, and would like to remove old machines out of a elastic load
balancer and substitute in new machines. I have something that looks like:
---
# rotate.yml
# NOTE: Doesn't work.
- name: Remove all non-new hosts from the QA appserver load balancer
hosts: tag_Env_qa:&tag_Role_appserver:!tag_Status_new
connection: local
vars:
region: ...
appserver_elb: dev
pre_tasks:
- name: Gathering ec2 facts
action: ec2_facts
tasks:
- name: Remove each host from the ELB
local_action: ec2_elb
args:
instance_id: "{{ ansible_ec2_instance_id }}"
region: "{{ region }}"
ec2_elbs: "{{ appserver_elb }}"
state: 'absent'
ec2_elb is failing: ansible_ec2_instance_id is undefined. True enough,
dumping all variables proves that it's not defined. From the examples I've
come across, it seems like this magic variable is getting set somewhere,
but I'm not seeing where or how (I figured ec2_facts would do it).
I feel like it would be more direct to directly interrogate the ELB for
it's members and then remove them. I didn't find an obvious way to do
that, so I went about it the other way (trying to leverage groups and
tagging things as "new").
I'd also totally believe there is a far better way of getting the same
basic result ("instantiate/rotate machines out of ELB"), and would be happy
to hear them.
--jesse
--
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/8f4675aa-dd2b-4c52-bad1-84bd91dd80ea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.