Author: | John Jarvis |
---|
New in version 1.2.
This module de-registers or registers an AWS EC2 instance from the ELBs that it belongs to. Returns fact “ec2_elbs” which is a list of elbs attached to the instance if state=absent is passed as an argument. Will be marked changed when called only if there are ELBs found to operate on.
parameter | required | default | choices | comments |
---|---|---|---|---|
aws_access_key | no | None | AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used. | |
aws_secret_key | no | None | AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used. | |
ec2_elbs | no | None | List of ELB names, required for registration. The ec2_elbs fact should be used if there was a previous de-register. | |
enable_availability_zone | no | True |
|
Whether to enable the availability zone of the instance on the target ELB if the availability zone has not already been enabled. If set to no, the task will fail if the availability zone is not enabled on the ELB. |
instance_id | yes | EC2 Instance ID | ||
region | no | The AWS region to use. If not specified then the value of the EC2_REGION environment variable, if any, is used. | ||
state | yes |
|
register or deregister the instance | |
validate_certs | no | yes |
|
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0. (added in Ansible 1.5) |
wait | no | True |
|
Wait for instance registration or deregistration to complete successfully before returning. |
Note
Requires boto
# basic pre_task and post_task example
pre_tasks:
- name: Gathering ec2 facts
ec2_facts:
- name: Instance De-register
local_action: ec2_elb
args:
instance_id: "{{ ansible_ec2_instance_id }}"
state: 'absent'
roles:
- myrole
post_tasks:
- name: Instance Register
local_action: ec2_elb
args:
instance_id: "{{ ansible_ec2_instance_id }}"
ec2_elbs: "{{ item }}"
state: 'present'
with_items: ec2_elbs