Apurv11

ELb

Nov 7th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. # get the public ip from instance id
  2. # IP=`aws ec2 describe-instances --instance-id i-03a598019b860ff29 --profile My_Own | grep ASSOCIATION | awk '{print $3}' | head -1`
  3. #
  4. ---
  5. - hosts: localhost
  6. connection: local
  7. gather_facts: no
  8. tasks:
  9. - name: Get the facts about the ELB
  10. ec2_elb_facts:
  11. names: TestELB
  12. region: "us-west-2"
  13. register: elb_facts
  14.  
  15. - name: Instance(s) ID that are currently registered to the ELB
  16. debug:
  17. #msg: "{{ elb_facts.elbs.0.instances }}"
  18. msg: "{{ elb_facts.elbs.0.instances.0 }}"
  19.  
  20. - name: remove an instance from ELB
  21. local_action: ec2_elb
  22. args:
  23. instance_id: "{{ elb_facts.elbs.0.instances.0 }}"
  24. #instance_id: "i-03a598019b860ff29"
  25. region: 'us-west-2'
  26. state: absent
  27. wait: yes
  28.  
  29. - name: Get the facts about the ELB
  30. ec2_elb_facts:
  31. names: TestELB
  32. region: "us-west-2"
  33. register: out_from_elb
  34.  
  35. #- name: find which instance is out from elb
  36. # shell: aws ec2 describe-instances --instance-id i-03a598019b860ff29 --profile My_Own | grep ASSOCIATION | awk '{print $3}'
  37. # pause: 10
  38.  
  39. - name: add instance back to ELB
  40. local_action: ec2_elb
  41. args:
  42. instance_id: "{{ elb_facts.elbs.0.instances.0 }}"
  43. #instance_id: "i-03a598019b860ff29"
  44. ec2_elbs: "TestELB"
  45. region: 'us-west-2'
  46. state: present
  47. wait: yes
Add Comment
Please, Sign In to add comment