wire_aggregator.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. ---
  2. - name: Make temp cert dir
  3. command: mktemp -d /tmp/openshift-service-catalog-ansible-XXXXXX
  4. register: certtemp
  5. changed_when: False
  6. - name: Check for First Master Aggregator Signer cert
  7. stat:
  8. path: /etc/origin/master/front-proxy-ca.crt
  9. register: first_proxy_ca_crt
  10. changed_when: false
  11. delegate_to: "{{ groups.oo_first_master.0 }}"
  12. - name: Check for First Master Aggregator Signer key
  13. stat:
  14. path: /etc/origin/master/front-proxy-ca.crt
  15. register: first_proxy_ca_key
  16. changed_when: false
  17. delegate_to: "{{ groups.oo_first_master.0 }}"
  18. # TODO: this currently has a bug where hostnames are required
  19. - name: Creating First Master Aggregator signer certs
  20. command: >
  21. {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm ca create-signer-cert
  22. --cert=/etc/origin/master/front-proxy-ca.crt
  23. --key=/etc/origin/master/front-proxy-ca.key
  24. --serial=/etc/origin/master/ca.serial.txt
  25. delegate_to: "{{ groups.oo_first_master.0 }}"
  26. when:
  27. - not first_proxy_ca_crt.stat.exists
  28. - not first_proxy_ca_key.stat.exists
  29. - name: Check for Aggregator Signer cert
  30. stat:
  31. path: /etc/origin/master/front-proxy-ca.crt
  32. register: proxy_ca_crt
  33. changed_when: false
  34. - name: Check for Aggregator Signer key
  35. stat:
  36. path: /etc/origin/master/front-proxy-ca.crt
  37. register: proxy_ca_key
  38. changed_when: false
  39. - name: Copy Aggregator Signer certs from first master
  40. fetch:
  41. src: "/etc/origin/master/{{ item }}"
  42. dest: "{{ certtemp.stdout }}/{{ item }}"
  43. flat: yes
  44. with_items:
  45. - front-proxy-ca.crt
  46. - front-proxy-ca.key
  47. delegate_to: "{{ groups.oo_first_master.0 }}"
  48. when:
  49. - not proxy_ca_key.stat.exists
  50. - not proxy_ca_crt.stat.exists
  51. - name: Copy Aggregator Signer certs to host
  52. copy:
  53. src: "{{ certtemp.stdout }}/{{ item }}"
  54. dest: "/etc/origin/master/{{ item }}"
  55. with_items:
  56. - front-proxy-ca.crt
  57. - front-proxy-ca.key
  58. when:
  59. - not proxy_ca_key.stat.exists
  60. - not proxy_ca_crt.stat.exists
  61. # oc_adm_ca_server_cert:
  62. # cert: /etc/origin/master/front-proxy-ca.crt
  63. # key: /etc/origin/master/front-proxy-ca.key
  64. - name: Check for first master api-client config
  65. stat:
  66. path: /etc/origin/master/aggregator-front-proxy.kubeconfig
  67. register: first_front_proxy_kubeconfig
  68. delegate_to: "{{ groups.oo_first_master.0 }}"
  69. run_once: true
  70. # create-api-client-config generates a ca.crt file which will
  71. # overwrite the OpenShift CA certificate. Generate the aggregator
  72. # kubeconfig in a temporary directory and then copy files into the
  73. # master config dir to avoid overwriting ca.crt.
  74. - block:
  75. - name: Create first master api-client config for Aggregator
  76. command: >
  77. {{ hostvars[groups.oo_first_master.0].openshift.common.client_binary }} adm create-api-client-config
  78. --certificate-authority=/etc/origin/master/front-proxy-ca.crt
  79. --signer-cert=/etc/origin/master/front-proxy-ca.crt
  80. --signer-key=/etc/origin/master/front-proxy-ca.key
  81. --user aggregator-front-proxy
  82. --client-dir={{ certtemp.stdout }}
  83. --signer-serial=/etc/origin/master/ca.serial.txt
  84. delegate_to: "{{ groups.oo_first_master.0 }}"
  85. run_once: true
  86. - name: Copy first master api-client config for Aggregator
  87. copy:
  88. src: "{{ certtemp.stdout }}/{{ item }}"
  89. dest: "/etc/origin/master/"
  90. remote_src: true
  91. with_items:
  92. - aggregator-front-proxy.crt
  93. - aggregator-front-proxy.key
  94. - aggregator-front-proxy.kubeconfig
  95. delegate_to: "{{ groups.oo_first_master.0 }}"
  96. run_once: true
  97. when:
  98. - not first_front_proxy_kubeconfig.stat.exists
  99. - name: Check for api-client config
  100. stat:
  101. path: /etc/origin/master/aggregator-front-proxy.kubeconfig
  102. register: front_proxy_kubeconfig
  103. - name: Copy api-client config from first master
  104. fetch:
  105. src: "/etc/origin/master/{{ item }}"
  106. dest: "{{ certtemp.stdout }}/{{ item }}"
  107. flat: yes
  108. delegate_to: "{{ groups.oo_first_master.0 }}"
  109. with_items:
  110. - aggregator-front-proxy.crt
  111. - aggregator-front-proxy.key
  112. - aggregator-front-proxy.kubeconfig
  113. when:
  114. - not front_proxy_kubeconfig.stat.exists
  115. - name: Copy api-client config to host
  116. copy:
  117. src: "{{ certtemp.stdout }}/{{ item }}"
  118. dest: "/etc/origin/master/{{ item }}"
  119. with_items:
  120. - aggregator-front-proxy.crt
  121. - aggregator-front-proxy.key
  122. - aggregator-front-proxy.kubeconfig
  123. when:
  124. - not front_proxy_kubeconfig.stat.exists
  125. - name: copy tech preview extension file for service console UI
  126. copy:
  127. src: openshift-ansible-catalog-console.js
  128. dest: /etc/origin/master/openshift-ansible-catalog-console.js
  129. - name: Update master config
  130. yedit:
  131. state: present
  132. src: /etc/origin/master/master-config.yaml
  133. edits:
  134. - key: aggregatorConfig.proxyClientInfo.certFile
  135. value: aggregator-front-proxy.crt
  136. - key: aggregatorConfig.proxyClientInfo.keyFile
  137. value: aggregator-front-proxy.key
  138. - key: authConfig.requestHeader.clientCA
  139. value: front-proxy-ca.crt
  140. - key: authConfig.requestHeader.clientCommonNames
  141. value: [aggregator-front-proxy]
  142. - key: authConfig.requestHeader.usernameHeaders
  143. value: [X-Remote-User]
  144. - key: authConfig.requestHeader.groupHeaders
  145. value: [X-Remote-Group]
  146. - key: authConfig.requestHeader.extraHeaderPrefixes
  147. value: [X-Remote-Extra-]
  148. - key: assetConfig.extensionScripts
  149. value: [/etc/origin/master/openshift-ansible-catalog-console.js]
  150. - key: kubernetesMasterConfig.apiServerArguments.runtime-config
  151. value: [apis/settings.k8s.io/v1alpha1=true]
  152. - key: admissionConfig.pluginConfig.PodPreset.configuration.kind
  153. value: DefaultAdmissionConfig
  154. - key: admissionConfig.pluginConfig.PodPreset.configuration.apiVersion
  155. value: v1
  156. - key: admissionConfig.pluginConfig.PodPreset.configuration.disable
  157. value: false
  158. register: yedit_output
  159. #restart master serially here
  160. - name: restart master api
  161. systemd: name={{ openshift.common.service_type }}-master-api state=restarted
  162. when:
  163. - yedit_output.changed
  164. - openshift.master.cluster_method == 'native'
  165. # We retry the controllers because the API may not be 100% initialized yet.
  166. - name: restart master controllers
  167. command: "systemctl restart {{ openshift.common.service_type }}-master-controllers"
  168. retries: 3
  169. delay: 5
  170. register: result
  171. until: result.rc == 0
  172. when:
  173. - yedit_output.changed
  174. - openshift.master.cluster_method == 'native'
  175. - name: Verify API Server
  176. # Using curl here since the uri module requires python-httplib2 and
  177. # wait_for port doesn't provide health information.
  178. command: >
  179. curl --silent --tlsv1.2
  180. {% if openshift.common.version_gte_3_2_or_1_2 | bool %}
  181. --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
  182. {% else %}
  183. --cacert {{ openshift.common.config_base }}/master/ca.crt
  184. {% endif %}
  185. {{ openshift.master.api_url }}/healthz/ready
  186. args:
  187. # Disables the following warning:
  188. # Consider using get_url or uri module rather than running curl
  189. warn: no
  190. register: api_available_output
  191. until: api_available_output.stdout == 'ok'
  192. retries: 120
  193. delay: 1
  194. changed_when: false
  195. when:
  196. - yedit_output.changed
  197. - name: Delete temp directory
  198. file:
  199. name: "{{ certtemp.stdout }}"
  200. state: absent
  201. changed_when: False