provision.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. ---
  2. - name: Setup the vpc and the master node group
  3. hosts: localhost
  4. tasks:
  5. - name: get provisioning vars
  6. include_vars: vars.yml
  7. - name: create default vpc
  8. include_role:
  9. name: openshift_aws_vpc
  10. vars:
  11. r_openshift_aws_vpc_clusterid: "{{ provision.clusterid }}"
  12. r_openshift_aws_vpc_cidr: "{{ provision.vpc.cidr }}"
  13. r_openshift_aws_vpc_subnets: "{{ provision.vpc.subnets }}"
  14. r_openshift_aws_vpc_region: "{{ provision.region }}"
  15. r_openshift_aws_vpc_tags: "{{ provision.vpc.tags }}"
  16. r_openshift_aws_vpc_name: "{{ provision.vpc.name | default(provision.clusterid) }}"
  17. - name: create aws ssh keypair
  18. include_role:
  19. name: openshift_aws_ssh_keys
  20. vars:
  21. r_openshift_aws_ssh_keys_users: "{{ provision.instance_users }}"
  22. r_openshift_aws_ssh_keys_region: "{{ provision.region }}"
  23. - when: provision.openshift_registry_s3 | default(false)
  24. name: create s3 bucket for registry
  25. include_role:
  26. name: openshift_aws_s3
  27. vars:
  28. r_openshift_aws_s3_clusterid: "{{ provision.clusterid }}-docker-registry"
  29. r_openshift_aws_s3_region: "{{ provision.region }}"
  30. r_openshift_aws_s3_mode: create
  31. - name: include scale group creation for master
  32. include: build_node_group.yml
  33. vars:
  34. openshift_build_node_type: master
  35. - name: fetch new master instances
  36. ec2_remote_facts:
  37. region: "{{ provision.region }}"
  38. filters:
  39. "tag:clusterid": "{{ provision.clusterid }}"
  40. "tag:host-type": master
  41. instance-state-name: running
  42. register: instancesout
  43. retries: 20
  44. delay: 3
  45. until: instancesout.instances|length > 0
  46. - name: bring iam_cert23 into scope
  47. include_role:
  48. name: lib_utils
  49. - name: upload certificates to AWS IAM
  50. iam_cert23:
  51. state: present
  52. name: "{{ provision.clusterid }}-master-external"
  53. cert: "{{ provision.iam_cert_ca.cert_path }}"
  54. key: "{{ provision.iam_cert_ca.key_path }}"
  55. cert_chain: "{{ provision.iam_cert_ca.chain_path | default(omit) }}"
  56. register: elb_cert_chain
  57. failed_when:
  58. - "'failed' in elb_cert_chain"
  59. - elb_cert_chain.failed
  60. - "'msg' in elb_cert_chain"
  61. - "'already exists' not in elb_cert_chain.msg"
  62. when: provision.iam_cert_ca is defined
  63. - debug: var=elb_cert_chain
  64. - name: create our master external and internal load balancers
  65. include_role:
  66. name: openshift_aws_elb
  67. vars:
  68. r_openshift_aws_elb_clusterid: "{{ provision.clusterid }}"
  69. r_openshift_aws_elb_region: "{{ provision.region }}"
  70. r_openshift_aws_elb_instance_filter:
  71. "tag:clusterid": "{{ provision.clusterid }}"
  72. "tag:host-type": master
  73. instance-state-name: running
  74. r_openshift_aws_elb_type: master
  75. r_openshift_aws_elb_direction: "{{ elb_item }}"
  76. r_openshift_aws_elb_idle_timout: 400
  77. r_openshift_aws_elb_scheme: internet-facing
  78. r_openshift_aws_elb_security_groups:
  79. - "{{ provision.clusterid }}"
  80. - "{{ provision.clusterid }}_master"
  81. r_openshift_aws_elb_subnet_name: "{{ provision.vpc.subnets[provision.region][0].az }}"
  82. r_openshift_aws_elb_name: "{{ provision.clusterid }}-master-{{ elb_item }}"
  83. r_openshift_aws_elb_cert_arn: "{{ elb_cert_chain.arn }}"
  84. with_items:
  85. - internal
  86. - external
  87. loop_control:
  88. loop_var: elb_item
  89. - name: add new master to masters group
  90. add_host:
  91. groups: "masters,etcd,nodes"
  92. name: "{{ item.public_ip_address }}"
  93. hostname: "{{ provision.clusterid }}-master-{{ item.id[:-5] }}"
  94. with_items: "{{ instancesout.instances }}"
  95. - name: set facts for group normalization
  96. set_fact:
  97. cluster_id: "{{ provision.clusterid }}"
  98. cluster_env: "{{ provision.node_group_config.tags.environment | default('dev') }}"
  99. - name: wait for ssh to become available
  100. wait_for:
  101. port: 22
  102. host: "{{ item.public_ip_address }}"
  103. timeout: 300
  104. search_regex: OpenSSH
  105. with_items: "{{ instancesout.instances }}"
  106. - name: set the master facts for hostname to elb
  107. hosts: masters
  108. gather_facts: no
  109. remote_user: root
  110. tasks:
  111. - name: include vars
  112. include_vars: vars.yml
  113. - name: fetch elbs
  114. ec2_elb_facts:
  115. region: "{{ provision.region }}"
  116. names:
  117. - "{{ item }}"
  118. with_items:
  119. - "{{ provision.clusterid }}-master-external"
  120. - "{{ provision.clusterid }}-master-internal"
  121. delegate_to: localhost
  122. register: elbs
  123. - debug: var=elbs
  124. - name: set fact
  125. set_fact:
  126. openshift_master_cluster_hostname: "{{ elbs.results[1].elbs[0].dns_name }}"
  127. osm_custom_cors_origins:
  128. - "{{ elbs.results[1].elbs[0].dns_name }}"
  129. - "console.{{ provision.clusterid }}.openshift.com"
  130. - "api.{{ provision.clusterid }}.openshift.com"
  131. with_items: "{{ groups['masters'] }}"
  132. - name: normalize groups
  133. include: ../../byo/openshift-cluster/initialize_groups.yml
  134. - name: run the std_include
  135. include: ../../common/openshift-cluster/std_include.yml
  136. - name: run the config
  137. include: ../../common/openshift-cluster/config.yml