install.yml 7.3 KB

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