main.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. ---
  2. # TODO: add ability to configure certificates given either a local file to
  3. # point to or certificate contents, set in default cert locations.
  4. # Authentication Variable Validation
  5. # TODO: validate the different identity provider kinds as well
  6. - fail:
  7. msg: >
  8. Invalid OAuth grant method: {{ openshift_master_oauth_grant_method }}
  9. when:
  10. - openshift_master_oauth_grant_method is defined
  11. - openshift_master_oauth_grant_method not in openshift_master_valid_grant_methods
  12. - name: Open up firewall ports
  13. import_tasks: firewall.yml
  14. - name: Prepare static pod scripts
  15. import_tasks: static_shim.yml
  16. - name: Create r_openshift_master_data_dir
  17. file:
  18. path: "{{ r_openshift_master_data_dir }}"
  19. state: directory
  20. mode: 0755
  21. owner: root
  22. group: root
  23. - name: Create config parent directory if it does not exist
  24. file:
  25. path: "{{ openshift_master_config_dir }}"
  26. state: directory
  27. - name: Create the policy file if it does not already exist
  28. command: >
  29. {{ openshift_client_binary }} adm create-bootstrap-policy-file
  30. --filename={{ openshift_master_policy }}
  31. args:
  32. creates: "{{ openshift_master_policy }}"
  33. - name: Create the scheduler config
  34. copy:
  35. content: "{{ scheduler_config | to_nice_json }}"
  36. dest: "{{ openshift_master_scheduler_conf }}"
  37. backup: true
  38. - name: Install httpd-tools if needed
  39. package: name=httpd-tools state=present
  40. when:
  41. - item.kind == 'HTPasswdPasswordIdentityProvider'
  42. - not openshift_is_atomic | bool
  43. with_items: "{{ openshift_master_identity_providers }}"
  44. register: result
  45. until: result is succeeded
  46. - name: Ensure htpasswd directory exists
  47. file:
  48. path: "{{ item.filename | dirname }}"
  49. state: directory
  50. when:
  51. - item.kind == 'HTPasswdPasswordIdentityProvider'
  52. with_items: "{{ openshift_master_identity_providers }}"
  53. - name: Create the htpasswd file if needed
  54. template:
  55. dest: "{{ item.filename }}"
  56. src: htpasswd.j2
  57. backup: yes
  58. mode: 0600
  59. when:
  60. - item.kind == 'HTPasswdPasswordIdentityProvider'
  61. - openshift.master.manage_htpasswd | bool
  62. with_items: "{{ openshift_master_identity_providers }}"
  63. - name: Ensure htpasswd file exists
  64. copy:
  65. dest: "{{ item.filename }}"
  66. force: no
  67. content: ""
  68. mode: 0600
  69. when:
  70. - item.kind == 'HTPasswdPasswordIdentityProvider'
  71. with_items: "{{ openshift_master_identity_providers }}"
  72. - name: Create the ldap ca file if needed
  73. copy:
  74. dest: "{{ item.ca if 'ca' in item and '/' in item.ca else openshift_master_config_dir ~ '/' ~ item.ca | default('ldap_ca.crt') }}"
  75. content: "{{ openshift.master.ldap_ca }}"
  76. mode: 0600
  77. backup: yes
  78. when:
  79. - openshift.master.ldap_ca is defined
  80. - item.kind == 'LDAPPasswordIdentityProvider'
  81. with_items: "{{ openshift_master_identity_providers }}"
  82. - name: Create the openid ca file if needed
  83. copy:
  84. dest: "{{ item.ca if 'ca' in item and '/' in item.ca else openshift_master_config_dir ~ '/' ~ item.ca | default('openid_ca.crt') }}"
  85. content: "{{ openshift.master.openid_ca }}"
  86. mode: 0600
  87. backup: yes
  88. when:
  89. - openshift.master.openid_ca is defined
  90. - item.kind == 'OpenIDIdentityProvider'
  91. - item.ca | default('') != ''
  92. with_items: "{{ openshift_master_identity_providers }}"
  93. - name: Create the request header ca file if needed
  94. copy:
  95. dest: "{{ item.clientCA if 'clientCA' in item and '/' in item.clientCA else openshift_master_config_dir ~ '/' ~ item.clientCA | default('request_header_ca.crt') }}"
  96. content: "{{ openshift.master.request_header_ca }}"
  97. mode: 0600
  98. backup: yes
  99. when:
  100. - openshift.master.request_header_ca is defined
  101. - item.kind == 'RequestHeaderIdentityProvider'
  102. - item.clientCA | default('') != ''
  103. with_items: "{{ openshift_master_identity_providers }}"
  104. - name: Set fact of all etcd host IPs
  105. openshift_facts:
  106. role: common
  107. local_facts:
  108. no_proxy_etcd_host_ips: "{{ openshift_no_proxy_etcd_host_ips }}"
  109. - name: Create session secrets file
  110. template:
  111. dest: "{{ openshift_master_session_secrets_file }}"
  112. src: sessionSecretsFile.yaml.v1.j2
  113. owner: root
  114. group: root
  115. mode: 0600
  116. - set_fact:
  117. # translate_idps is a custom filter in role lib_utils
  118. translated_identity_providers: "{{ openshift_master_identity_providers | translate_idps('v1') }}"
  119. # TODO: add the validate parameter when there is a validation command to run
  120. - name: Create master config
  121. template:
  122. dest: "{{ openshift_master_config_file }}"
  123. src: master.yaml.v1.j2
  124. backup: true
  125. owner: root
  126. group: root
  127. mode: 0600
  128. - include_tasks: set_loopback_context.yml
  129. - name: Create the master service env file
  130. template:
  131. src: "master.env.j2"
  132. dest: /etc/origin/master/master.env
  133. backup: true
  134. - include_tasks: static.yml
  135. - name: Start and enable self-hosting node
  136. systemd:
  137. name: "{{ openshift_service_type }}-node"
  138. state: restarted
  139. enabled: yes
  140. register: node_start
  141. ignore_errors: yes
  142. - when: node_start is failed
  143. block:
  144. - name: Get node logs
  145. command: journalctl --no-pager -n 300 -u {{ openshift_service_type }}-node
  146. register: logs_node
  147. ignore_errors: true
  148. - debug:
  149. msg: "{{ logs_node.stdout_lines }}"
  150. - fail:
  151. msg: Node start failed.
  152. - name: Verify that the control plane is running
  153. command: >
  154. curl -k {{ openshift.master.api_url }}/healthz/ready
  155. args:
  156. # Disables the following warning:
  157. # Consider using get_url or uri module rather than running curl
  158. warn: no
  159. register: control_plane_health
  160. until: control_plane_health.stdout == 'ok'
  161. retries: 60
  162. delay: 5
  163. changed_when: false
  164. # Ignore errors so we can log troubleshooting info on failures.
  165. ignore_errors: yes
  166. # Capture debug output here to simplify triage
  167. - when: control_plane_health.stdout != 'ok'
  168. block:
  169. - name: Check status in the kube-system namespace
  170. command: >
  171. {{ openshift_client_binary }} status --config=/etc/origin/master/admin.kubeconfig -n kube-system
  172. register: control_plane_status
  173. ignore_errors: true
  174. - debug:
  175. msg: "{{ control_plane_status.stdout_lines }}"
  176. - name: Get pods in the kube-system namespace
  177. command: >
  178. {{ openshift_client_binary }} get pods --config=/etc/origin/master/admin.kubeconfig -n kube-system -o wide
  179. register: control_plane_pods
  180. ignore_errors: true
  181. - debug:
  182. msg: "{{ control_plane_pods.stdout_lines }}"
  183. - name: Get events in the kube-system namespace
  184. command: >
  185. {{ openshift_client_binary }} get events --config=/etc/origin/master/admin.kubeconfig -n kube-system
  186. register: control_plane_events
  187. ignore_errors: true
  188. - debug:
  189. msg: "{{ control_plane_events.stdout_lines }}"
  190. - name: Get API logs
  191. command: >
  192. /usr/local/bin/master-logs api api
  193. register: control_plane_logs_api
  194. ignore_errors: true
  195. - debug:
  196. msg: "{{ control_plane_logs_api.stdout_lines }}"
  197. - name: Get node logs
  198. command: journalctl --no-pager -n 300 -u {{ openshift_service_type }}-node
  199. register: control_plane_logs_node
  200. ignore_errors: true
  201. - debug:
  202. msg: "{{ control_plane_logs_node.stdout_lines }}"
  203. - name: Report control plane errors
  204. fail:
  205. msg: Control plane install failed.
  206. when: control_plane_health.stdout != 'ok'
  207. - include_tasks: bootstrap.yml