main.yml 7.1 KB

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