amazon ec2 - How to stop old instance from ELB in ansible? -


i have playbook creates , add instance load balancer, way can remove/stop old instance assigned elb, want make sure stop old instance first , new 1s added or vice verse. using aws elb , ec2 instance

i hope might you. once have instance id can whatever want, removing elb can use ec2 module remove it.

--- - hosts: localhost   connection: local   gather_facts: no   tasks:    - name: facts elb      ec2_elb_facts:        names: rbgeek-dev-web-elb        region: "eu-west-1"      register: elb_facts     - name: instance(s) id register elb      debug:        msg: "{{ elb_facts.elbs.0.instances }}"     - name: tag old instances zombie      ec2_tag:        resource: "{{ item }}"        region: "eu-west-1"        state: present        tags:          instance_status: "zombie"      with_items: "{{ elb_facts.elbs.0.instances }}"     - name: refresh ec2.py cache      shell: ./inventory/ec2.py --refresh-cache      changed_when: no     - name: refresh inventory      meta: refresh_inventory   # must check step ec2_remote_facts_module.html ##http://docs.ansible.com/ansible/ec2_remote_facts_module.html - hosts: tag_instance_status_zombie   gather_facts: no   tasks:     - name: facts zombie instances       ec2_facts:     - name: remove instance instance id       ec2:         state: absent         region: "eu-west-1"         instance_ids: "{{ ansible_ec2_instance_id }}"         wait: true       delegate_to: localhost 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -