Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # get the public ip from instance id
- # IP=`aws ec2 describe-instances --instance-id i-03a598019b860ff29 --profile My_Own | grep ASSOCIATION | awk '{print $3}' | head -1`
- #
- ---
- - hosts: localhost
- connection: local
- gather_facts: no
- tasks:
- - name: Get the facts about the ELB
- ec2_elb_facts:
- names: TestELB
- region: "us-west-2"
- register: elb_facts
- - name: Instance(s) ID that are currently registered to the ELB
- debug:
- #msg: "{{ elb_facts.elbs.0.instances }}"
- msg: "{{ elb_facts.elbs.0.instances.0 }}"
- - name: remove an instance from ELB
- local_action: ec2_elb
- args:
- instance_id: "{{ elb_facts.elbs.0.instances.0 }}"
- #instance_id: "i-03a598019b860ff29"
- region: 'us-west-2'
- state: absent
- wait: yes
- - name: Get the facts about the ELB
- ec2_elb_facts:
- names: TestELB
- region: "us-west-2"
- register: out_from_elb
- #- name: find which instance is out from elb
- # shell: aws ec2 describe-instances --instance-id i-03a598019b860ff29 --profile My_Own | grep ASSOCIATION | awk '{print $3}'
- # pause: 10
- - name: add instance back to ELB
- local_action: ec2_elb
- args:
- instance_id: "{{ elb_facts.elbs.0.instances.0 }}"
- #instance_id: "i-03a598019b860ff29"
- ec2_elbs: "TestELB"
- region: 'us-west-2'
- state: present
- wait: yes
Add Comment
Please, Sign In to add comment