---
- name: "dump the elb listeners for {{ item.key }}"
  debug:
    msg: "{{ item.value }}"
    verbosity: 1

- name: "Create ELB {{ item.value.name }}"
  ec2_elb_lb:
    name: "{{ item.value.name }}"
    state: present
    cross_az_load_balancing: "{{ item.value.cross_az_load_balancing }}"
    security_group_names: "{{ l_elb_security_groups[l_elb_dict_item.key] }}"
    idle_timeout: "{{ item.value.idle_timeout }}"
    region: "{{ openshift_aws_region }}"
    subnets: "{{ subnetout.results | map(attribute='subnets.0.subnet_id') | list }}"
    health_check: "{{ item.value.health_check }}"
    instance_ids: "{{ item.value.instance_ids | default(omit) }}"
    listeners: "{{ item.value.listeners }}"
    scheme: "{{ item.value.scheme | default('internal') }}"
    tags: "{{ item.value.tags }}"
    wait: True
  register: new_elb
  retries: 20
  delay: 5
  until: new_elb is succeeded
  ignore_errors: yes

- fail:
    msg: "couldn't create ELB {{ item.value.name }}"
  when: new_elb is failed

- debug:
    msg: "{{ new_elb }}"
    verbosity: 1
