deploy_cluster_40.yml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. ---
  2. - name: run the init
  3. import_playbook: init/main.yml
  4. vars:
  5. l_init_fact_hosts: "nodes"
  6. l_openshift_version_set_hosts: "nodes"
  7. l_install_base_packages: True
  8. l_repo_hosts: "all:!all"
  9. - name: Read in openshift-install
  10. hosts: masters[0]
  11. tasks:
  12. - slurp:
  13. src: "{{ openshift_install_config_path }}"
  14. register: openshift_install_config_reg
  15. delegate_to: localhost
  16. run_once: True
  17. - set_fact:
  18. openshift_install_config: "{{ openshift_install_config_reg['content'] | b64decode | from_yaml }}"
  19. # We might need to access these values on each host later.
  20. - name: set_fact openshift_install_config across all nodes
  21. hosts: nodes
  22. tasks:
  23. - set_fact:
  24. openshift_install_config: "{{ hostvars[groups['masters'][0]].openshift_install_config }}"
  25. # TODO(michaelgugino): break up the rest of this file into reusable chunks.
  26. - name: Install nodes
  27. hosts: nodes
  28. roles:
  29. - role: container_runtime
  30. tasks:
  31. - import_role:
  32. name: container_runtime
  33. tasks_from: docker_storage_setup_overlay.yml
  34. - import_role:
  35. name: container_runtime
  36. tasks_from: extra_storage_setup.yml
  37. - import_role:
  38. name: container_runtime
  39. tasks_from: package_crio.yml
  40. - import_role:
  41. name: openshift_node40
  42. tasks_from: install.yml
  43. - name: Config bootstrap node
  44. hosts: bootstrap
  45. tasks:
  46. - import_role:
  47. name: openshift_node40
  48. tasks_from: config.yml
  49. - import_role:
  50. name: openshift_node40
  51. tasks_from: systemd.yml
  52. vars:
  53. excluded_services:
  54. - progress.service
  55. - name: Start masters
  56. hosts: masters
  57. vars:
  58. openshift_bootstrap_endpoint: "{{ openshift_install_config['metadata']['name'] }}-api.{{ openshift_install_config['baseDomain'] }}:49500/config/master"
  59. tasks:
  60. - name: Wait for bootstrap endpoint to show up
  61. uri:
  62. url: "{{ openshift_bootstrap_endpoint }}"
  63. validate_certs: false
  64. delay: 10
  65. retries: 60
  66. register: result
  67. until:
  68. - "'status' in result"
  69. - result.status == 200
  70. - import_role:
  71. name: openshift_node40
  72. tasks_from: config.yml
  73. - name: Make sure etcd user exists
  74. user:
  75. name: etcd
  76. - import_role:
  77. name: openshift_node40
  78. tasks_from: systemd.yml
  79. - name: Start workers
  80. hosts: workers
  81. vars:
  82. openshift_bootstrap_endpoint: "{{ openshift_install_config['metadata']['name'] }}-api.{{ openshift_install_config['baseDomain'] }}:49500/config/worker"
  83. tasks:
  84. - name: Wait for bootstrap endpoint to show up
  85. uri:
  86. url: "{{ openshift_bootstrap_endpoint }}"
  87. validate_certs: false
  88. delay: 10
  89. retries: 60
  90. register: result
  91. until:
  92. - "'status' in result"
  93. - result.status == 200
  94. - import_role:
  95. name: openshift_node40
  96. tasks_from: config.yml
  97. - import_role:
  98. name: openshift_node40
  99. tasks_from: systemd.yml
  100. - name: Wait for nodes to become ready
  101. hosts: bootstrap
  102. tasks:
  103. - name: Wait for temporary control plane to show up
  104. oc_obj:
  105. state: list
  106. kind: pod
  107. namespace: kube-system
  108. kubeconfig: /opt/openshift/auth/kubeconfig
  109. register: control_plane_pods
  110. retries: 60
  111. delay: 10
  112. until:
  113. - "'results' in control_plane_pods and 'results' in control_plane_pods.results"
  114. - control_plane_pods.results.results[0]['items'] | length > 0
  115. - name: Wait for master nodes to show up
  116. oc_obj:
  117. state: list
  118. kind: node
  119. selector: "node-role.kubernetes.io/master"
  120. kubeconfig: /opt/openshift/auth/kubeconfig
  121. register: master_nodes
  122. retries: 60
  123. delay: 10
  124. until:
  125. - "'results' in master_nodes and 'results' in master_nodes.results"
  126. - master_nodes.results.results[0]['items'] | length > 0
  127. - name: Wait for bootkube service to finish
  128. service_facts: {}
  129. #10 mins to complete temp plane
  130. retries: 120
  131. delay: 5
  132. until: "'bootkube.service' not in ansible_facts.services"
  133. ignore_errors: true
  134. - name: Fetch kubeconfig for test container
  135. fetch:
  136. src: /opt/openshift/auth/kubeconfig
  137. dest: /tmp/artifacts/installer/auth/kubeconfig
  138. flat: yes
  139. - name: Wait for core operators to appear and complete
  140. oc_obj:
  141. state: list
  142. kind: ClusterOperator
  143. name: "{{ item }}"
  144. kubeconfig: /opt/openshift/auth/kubeconfig
  145. register: operator
  146. #Give each operator 5 mins to come up
  147. retries: 60
  148. delay: 5
  149. until:
  150. - "'results' in operator"
  151. - "'results' in operator.results"
  152. - operator.results.results | length > 0
  153. - "'status' in operator.results.results[0]"
  154. - "'conditions' in operator.results.results[0]['status']"
  155. - operator.results.results[0].status.conditions | selectattr('type', 'match', '^Available$') | map(attribute='status') | join | bool == True
  156. - operator.results.results[0].status.conditions | selectattr('type', 'match', '^Progressing$') | map(attribute='status') | join | bool == False
  157. - operator.results.results[0].status.conditions | selectattr('type', 'match', '^Failing$') | map(attribute='status') | join | bool == False
  158. with_items:
  159. - machine-config-operator
  160. # Fails often with 'x of y nodes are not at revision n'
  161. #- openshift-cluster-kube-apiserver-operator
  162. # Failing with 'ConfigObservationFailing: configmap/cluster-config-v1.kube-system: no recognized cloud provider platform found' - https://github.com/openshift/cluster-kube-controller-manager-operator/issues/100
  163. #- openshift-cluster-kube-controller-manager-operator
  164. # Fails often with 'x of y nodes are not at revision n'
  165. #- openshift-cluster-kube-scheduler-operator
  166. #- openshift-cluster-openshift-apiserver-operator
  167. - openshift-cluster-openshift-controller-manager-operator
  168. - openshift-ingress-operator
  169. ignore_errors: true
  170. - block:
  171. - name: Output the operators status
  172. oc_obj:
  173. state: list
  174. kind: ClusterOperator
  175. selector: ""
  176. kubeconfig: /opt/openshift/auth/kubeconfig
  177. - fail:
  178. msg: Required operators didn't complete the install
  179. when: operator.failed