install.yml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. ---
  2. # do any asserts here
  3. - name: Create temp directory for doing work in
  4. command: mktemp -d /tmp/openshift-service-catalog-ansible-XXXXXX
  5. register: mktemp
  6. changed_when: False
  7. - name: Set default image variables based on openshift_deployment_type
  8. include_vars: "{{ item }}"
  9. with_first_found:
  10. - "{{ openshift_deployment_type }}.yml"
  11. - "default_images.yml"
  12. - name: Set service_catalog image facts
  13. set_fact:
  14. openshift_service_catalog_image_prefix: "{{ openshift_service_catalog_image_prefix | default(__openshift_service_catalog_image_prefix) }}"
  15. openshift_service_catalog_image_version: "{{ openshift_service_catalog_image_version | default(__openshift_service_catalog_image_version) }}"
  16. - name: Set Service Catalog namespace
  17. oc_project:
  18. state: present
  19. name: "kube-service-catalog"
  20. node_selector: ""
  21. - when: os_sdn_network_plugin_name == 'redhat/openshift-ovs-multitenant'
  22. block:
  23. - name: Waiting for netnamespace kube-service-catalog to be ready
  24. oc_obj:
  25. kind: netnamespace
  26. name: kube-service-catalog
  27. state: list
  28. register: get_output
  29. until: not get_output.results.stderr is defined
  30. retries: 30
  31. delay: 1
  32. changed_when: false
  33. - name: Make kube-service-catalog project network global
  34. command: >
  35. {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig adm pod-network make-projects-global kube-service-catalog
  36. - include_tasks: generate_certs.yml
  37. - copy:
  38. src: kubeservicecatalog_roles_bindings.yml
  39. dest: "{{ mktemp.stdout }}/kubeservicecatalog_roles_bindings.yml"
  40. - oc_obj:
  41. name: service-catalog-role-bindings
  42. kind: template
  43. namespace: "kube-service-catalog"
  44. files:
  45. - "{{ mktemp.stdout }}/kubeservicecatalog_roles_bindings.yml"
  46. - oc_process:
  47. create: True
  48. template_name: service-catalog-role-bindings
  49. namespace: "kube-service-catalog"
  50. - copy:
  51. src: kubesystem_roles_bindings.yml
  52. dest: "{{ mktemp.stdout }}/kubesystem_roles_bindings.yml"
  53. - oc_obj:
  54. name: kube-system-service-catalog-role-bindings
  55. kind: template
  56. namespace: kube-system
  57. files:
  58. - "{{ mktemp.stdout }}/kubesystem_roles_bindings.yml"
  59. - oc_process:
  60. create: True
  61. template_name: kube-system-service-catalog-role-bindings
  62. namespace: kube-system
  63. - oc_obj:
  64. name: edit
  65. kind: clusterrole
  66. state: list
  67. register: edit_yaml
  68. # only do this if we don't already have the updated role info
  69. - name: Generate apply template for clusterrole/edit
  70. template:
  71. src: sc_admin_edit_role_patching.j2
  72. dest: "{{ mktemp.stdout }}/edit_sc_patch.yml"
  73. vars:
  74. original_content: "{{ edit_yaml.results.results[0] | to_yaml }}"
  75. when:
  76. - not edit_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['create', 'update', 'delete', 'get', 'list', 'watch', 'patch']) or not edit_yaml.results.results[0] | lib_utils_oo_contains_rule(['settings.k8s.io'], ['podpresets'], ['create', 'update', 'delete', 'get', 'list', 'watch'])
  77. # only do this if we don't already have the updated role info
  78. - name: update edit role for service catalog and pod preset access
  79. command: >
  80. {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig replace -f {{ mktemp.stdout }}/edit_sc_patch.yml
  81. when:
  82. - not edit_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['create', 'update', 'delete', 'get', 'list', 'watch', 'patch']) or not edit_yaml.results.results[0] | lib_utils_oo_contains_rule(['settings.k8s.io'], ['podpresets'], ['create', 'update', 'delete', 'get', 'list', 'watch'])
  83. - oc_obj:
  84. name: admin
  85. kind: clusterrole
  86. state: list
  87. register: admin_yaml
  88. # only do this if we don't already have the updated role info
  89. - name: Generate apply template for clusterrole/admin
  90. template:
  91. src: sc_admin_edit_role_patching.j2
  92. dest: "{{ mktemp.stdout }}/admin_sc_patch.yml"
  93. vars:
  94. original_content: "{{ admin_yaml.results.results[0] | to_yaml }}"
  95. when:
  96. - not admin_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['create', 'update', 'delete', 'get', 'list', 'watch', 'patch']) or not admin_yaml.results.results[0] | lib_utils_oo_contains_rule(['settings.k8s.io'], ['podpresets'], ['create', 'update', 'delete', 'get', 'list', 'watch'])
  97. # only do this if we don't already have the updated role info
  98. - name: update admin role for service catalog and pod preset access
  99. command: >
  100. {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig replace -f {{ mktemp.stdout }}/admin_sc_patch.yml
  101. when:
  102. - not admin_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['create', 'update', 'delete', 'get', 'list', 'watch', 'patch']) or not admin_yaml.results.results[0] | lib_utils_oo_contains_rule(['settings.k8s.io'], ['podpresets'], ['create', 'update', 'delete', 'get', 'list', 'watch'])
  103. - oc_obj:
  104. name: view
  105. kind: clusterrole
  106. state: list
  107. register: view_yaml
  108. # only do this if we don't already have the updated role info
  109. - name: Generate apply template for clusterrole/view
  110. template:
  111. src: sc_view_role_patching.j2
  112. dest: "{{ mktemp.stdout }}/view_sc_patch.yml"
  113. vars:
  114. original_content: "{{ view_yaml.results.results[0] | to_yaml }}"
  115. when:
  116. - not view_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['get', 'list', 'watch'])
  117. # only do this if we don't already have the updated role info
  118. - name: update view role for service catalog access
  119. command: >
  120. {{ openshift_client_binary }} --config=/etc/origin/master/admin.kubeconfig replace -f {{ mktemp.stdout }}/view_sc_patch.yml
  121. when:
  122. - not view_yaml.results.results[0] | lib_utils_oo_contains_rule(['servicecatalog.k8s.io'], ['serviceinstances', 'servicebindings'], ['get', 'list', 'watch'])
  123. - oc_adm_policy_user:
  124. namespace: kube-service-catalog
  125. resource_kind: scc
  126. resource_name: hostmount-anyuid
  127. state: present
  128. user: "system:serviceaccount:kube-service-catalog:service-catalog-apiserver"
  129. - name: Set SA cluster-role
  130. oc_adm_policy_user:
  131. state: present
  132. namespace: "kube-service-catalog"
  133. resource_kind: cluster-role
  134. resource_name: admin
  135. user: "system:serviceaccount:kube-service-catalog:default"
  136. - name: Checking for master.etcd-ca.crt
  137. stat:
  138. path: /etc/origin/master/master.etcd-ca.crt
  139. register: etcd_ca_crt
  140. check_mode: no
  141. ## api server
  142. - template:
  143. src: api_server.j2
  144. dest: "{{ mktemp.stdout }}/service_catalog_api_server.yml"
  145. vars:
  146. image: ""
  147. namespace: ""
  148. cpu_limit: none
  149. memory_limit: none
  150. cpu_requests: none
  151. memory_request: none
  152. cors_allowed_origin: localhost
  153. etcd_servers: "{{ openshift.master.etcd_urls | join(',') }}"
  154. etcd_cafile: "{{ '/etc/origin/master/master.etcd-ca.crt' if etcd_ca_crt.stat.exists else '/etc/origin/master/ca-bundle.crt' }}"
  155. node_selector: "{{ openshift_service_catalog_nodeselector | default ({'openshift-infra': 'apiserver'}) }}"
  156. - name: Set Service Catalog API Server daemonset
  157. oc_obj:
  158. state: present
  159. namespace: "kube-service-catalog"
  160. kind: daemonset
  161. name: apiserver
  162. files:
  163. - "{{ mktemp.stdout }}/service_catalog_api_server.yml"
  164. delete_after: yes
  165. - name: Set Service Catalog API Server service
  166. oc_service:
  167. name: apiserver
  168. namespace: kube-service-catalog
  169. state: present
  170. ports:
  171. - name: secure
  172. port: 443
  173. protocol: TCP
  174. targetPort: 6443
  175. selector:
  176. app: apiserver
  177. session_affinity: None
  178. - template:
  179. src: api_server_route.j2
  180. dest: "{{ mktemp.stdout }}/service_catalog_api_route.yml"
  181. - name: Set Service Catalog API Server route
  182. oc_obj:
  183. state: present
  184. namespace: "kube-service-catalog"
  185. kind: route
  186. name: apiserver
  187. files:
  188. - "{{ mktemp.stdout }}/service_catalog_api_route.yml"
  189. delete_after: yes
  190. ## controller manager
  191. - template:
  192. src: controller_manager.j2
  193. dest: "{{ mktemp.stdout }}/controller_manager.yml"
  194. vars:
  195. image: ""
  196. cpu_limit: none
  197. memory_limit: none
  198. node_selector: "{{ openshift_service_catalog_nodeselector | default ({'openshift-infra': 'apiserver'}) }}"
  199. - name: Set Controller Manager deployment
  200. oc_obj:
  201. state: present
  202. namespace: "kube-service-catalog"
  203. kind: daemonset
  204. name: controller-manager
  205. files:
  206. - "{{ mktemp.stdout }}/controller_manager.yml"
  207. delete_after: yes
  208. - name: Set Controller Manager service
  209. oc_service:
  210. name: controller-manager
  211. namespace: kube-service-catalog
  212. state: present
  213. ports:
  214. - port: 6443
  215. protocol: TCP
  216. targetPort: 6443
  217. selector:
  218. app: controller-manager
  219. session_affinity: None
  220. service_type: ClusterIP
  221. - include_tasks: start_api_server.yml
  222. - name: Delete temp directory
  223. file:
  224. name: "{{ mktemp.stdout }}"
  225. state: absent
  226. changed_when: False