---
- name: Register EC2 instances to internet-facing master ELB
  ignore_errors: yes
  ec2_elb:
    instance_id: "{{ item.tagged_instances[0].id }}"
    ec2_elbs: "{{ elbextmaster.elb.name }}"
    region: "{{ aws_region }}"
    state: present
  with_items:
    - "{{ ec2master.results }}"
  register: test
  failed_when: "'InvalidInstanceID.NotFound' in test"

- name: Register EC2 instances to internal master ELB
  ignore_errors: yes
  ec2_elb:
    instance_id: "{{ item.tagged_instances[0].id }}"
    ec2_elbs: "{{ elbintmaster.elb.name }}"
    region: "{{ aws_region }}"
    state: present
  with_items:
    - "{{ ec2master.results }}"
  register: test
  failed_when: "'InvalidInstanceID.NotFound' in test"

- name: Register EC2 instances to internet-facing infra ELB
  ignore_errors: yes
  ec2_elb:
    instance_id: "{{ item.tagged_instances[0].id }}"
    ec2_elbs: "{{ elbextinfra.elb.name }}"
    region: "{{ aws_region }}"
    state: present
  with_items:
    - "{{ ec2infra.results }}"
  register: test
  failed_when: "'InvalidInstanceID.NotFound' in test"
