main.yml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. ---
  2. - name: fetch the default subnet id
  3. ec2_remote_facts:
  4. region: "{{ r_openshift_aws_elb_region }}"
  5. filters: "{{ r_openshift_aws_elb_instance_filter }}"
  6. register: instancesout
  7. - name: fetch the default subnet id
  8. ec2_vpc_subnet_facts:
  9. region: "{{ r_openshift_aws_elb_region }}"
  10. filters:
  11. "tag:Name": "{{ r_openshift_aws_elb_subnet_name }}"
  12. register: subnetout
  13. - name:
  14. debug:
  15. msg: "{{ r_openshift_aws_elb_listeners[r_openshift_aws_elb_type][r_openshift_aws_elb_direction]
  16. if 'master' in r_openshift_aws_elb_type or 'infra' in r_openshift_aws_elb_type
  17. else r_openshift_aws_elb_listeners }}"
  18. - name: "Create ELB {{ r_openshift_aws_elb_name }}"
  19. ec2_elb_lb:
  20. name: "{{ r_openshift_aws_elb_name }}"
  21. state: present
  22. security_group_names: "{{ r_openshift_aws_elb_security_groups }}"
  23. idle_timeout: "{{ r_openshift_aws_elb_idle_timout }}"
  24. region: "{{ r_openshift_aws_elb_region }}"
  25. subnets:
  26. - "{{ subnetout.subnets[0].id }}"
  27. health_check: "{{ r_openshift_aws_elb_health_check }}"
  28. listeners: "{{ r_openshift_aws_elb_listeners[r_openshift_aws_elb_type][r_openshift_aws_elb_direction]
  29. if 'master' in r_openshift_aws_elb_type or 'infra' in r_openshift_aws_elb_type
  30. else r_openshift_aws_elb_listeners }}"
  31. scheme: "{{ r_openshift_aws_elb_scheme }}"
  32. tags:
  33. KubernetesCluster: "{{ r_openshift_aws_elb_clusterid }}"
  34. register: new_elb
  35. # It is necessary to ignore_errors here because the instances are not in 'ready'
  36. # state when first added to ELB
  37. - name: "Add instances to ELB {{ r_openshift_aws_elb_name }}"
  38. ec2_elb:
  39. instance_id: "{{ item.id }}"
  40. ec2_elbs: "{{ r_openshift_aws_elb_name }}"
  41. state: present
  42. region: "{{ r_openshift_aws_elb_region }}"
  43. wait: False
  44. with_items: "{{ instancesout.instances }}"
  45. ignore_errors: True
  46. retries: 10
  47. register: elb_call
  48. until: elb_call|succeeded
  49. - debug:
  50. msg: "{{ item }}"
  51. with_items:
  52. - "{{ new_elb }}"