Adding an ec2_elb test to re-add an instance that had been removed

This commit is contained in:
James Cammarata 2014-04-30 13:58:18 -05:00
parent 93fb82a5a1
commit bf7c51ad8a

View file

@ -89,24 +89,6 @@
# ============================================================
# shutdown http first instance so it goes out of service
#- name: terminate first instance
# ec2:
# ec2_access_key: "{{ ec2_access_key }}"
# ec2_secret_key: "{{ ec2_secret_key }}"
# region: "{{ ec2_region }}"
# state: 'absent'
# instance_ids: "{{ ec2_provision_result.instance_ids[0] }}"
# register: result
#
#- name: assert the instance was terminated
# assert:
# that:
# - 'result.changed == True'
# - 'result.instance_ids[0] == ec2_provision_result.instance_ids[0]'
#
#- name: wait for the instance to die
# wait_for: port=80 host="{{ec2_provision_result.instances[0].public_ip}}" state=absent
- name: "shutdown the apache service on the first instance ({{ec2_provision_result.instances[0].public_ip}})"
service: name=httpd state=stopped
remote_user: "ec2-user"
@ -162,6 +144,26 @@
- 'result.changed == True'
- '"{{resource_prefix}}" in result.ansible_facts.ec2_elbs'
# ============================================================
# re-register the second instance (issue #4902)
- name: re-register the second instance (issue #4902)
ec2_elb:
ec2_elbs: "{{ resource_prefix }}"
ec2_access_key: "{{ ec2_access_key }}"
ec2_secret_key: "{{ ec2_secret_key }}"
region: "{{ ec2_region }}"
instance_id: "{{ ec2_provision_result.instance_ids[1] }}"
state: present
wait_timeout: 300
register: result
- name: assert the instance was re-registered ok
assert:
that:
- 'result.changed == True'
- '"{{resource_prefix}}" in result.ansible_facts.ec2_elbs'
# ============================================================
# remove all other instances
@ -174,7 +176,7 @@
instance_id: "{{ item }}"
state: absent
wait_timeout: 300
with_items: "ec2_provision_result.instance_ids[2:]"
with_items: "ec2_provision_result.instance_ids[1:]"
register: result
- name: assert the other instances were removed