install.yml 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. - shell: >
  96. oc get policybindings/kube-system:default -n kube-system || echo "not found"
  97. register: get_kube_system
  98. changed_when: no
  99. - command: >
  100. oc create policybinding kube-system -n kube-system
  101. when: "'not found' in get_kube_system.stdout"
  102. - oc_adm_policy_user:
  103. namespace: kube-service-catalog
  104. resource_kind: scc
  105. resource_name: hostmount-anyuid
  106. state: present
  107. user: "system:serviceaccount:kube-service-catalog:service-catalog-apiserver"
  108. - name: Set SA cluster-role
  109. oc_adm_policy_user:
  110. state: present
  111. namespace: "kube-service-catalog"
  112. resource_kind: cluster-role
  113. resource_name: admin
  114. user: "system:serviceaccount:kube-service-catalog:default"
  115. - name: Checking for master.etcd-ca.crt
  116. stat:
  117. path: /etc/origin/master/master.etcd-ca.crt
  118. register: etcd_ca_crt
  119. check_mode: no
  120. ## api server
  121. - template:
  122. src: api_server.j2
  123. dest: "{{ mktemp.stdout }}/service_catalog_api_server.yml"
  124. vars:
  125. image: ""
  126. namespace: ""
  127. cpu_limit: none
  128. memory_limit: none
  129. cpu_requests: none
  130. memory_request: none
  131. cors_allowed_origin: localhost
  132. etcd_servers: "{{ openshift.master.etcd_urls | join(',') }}"
  133. etcd_cafile: "{{ '/etc/origin/master/master.etcd-ca.crt' if etcd_ca_crt.stat.exists else '/etc/origin/master/ca-bundle.crt' }}"
  134. node_selector: "{{ openshift_service_catalog_nodeselector | default ({'openshift-infra': 'apiserver'}) }}"
  135. - name: Set Service Catalog API Server daemonset
  136. oc_obj:
  137. state: present
  138. namespace: "kube-service-catalog"
  139. kind: daemonset
  140. name: apiserver
  141. files:
  142. - "{{ mktemp.stdout }}/service_catalog_api_server.yml"
  143. delete_after: yes
  144. - name: Set Service Catalog API Server service
  145. oc_service:
  146. name: apiserver
  147. namespace: kube-service-catalog
  148. state: present
  149. ports:
  150. - name: secure
  151. port: 443
  152. protocol: TCP
  153. targetPort: 6443
  154. selector:
  155. app: apiserver
  156. session_affinity: None
  157. - template:
  158. src: api_server_route.j2
  159. dest: "{{ mktemp.stdout }}/service_catalog_api_route.yml"
  160. - name: Set Service Catalog API Server route
  161. oc_obj:
  162. state: present
  163. namespace: "kube-service-catalog"
  164. kind: route
  165. name: apiserver
  166. files:
  167. - "{{ mktemp.stdout }}/service_catalog_api_route.yml"
  168. delete_after: yes
  169. ## controller manager
  170. - template:
  171. src: controller_manager.j2
  172. dest: "{{ mktemp.stdout }}/controller_manager.yml"
  173. vars:
  174. image: ""
  175. cpu_limit: none
  176. memory_limit: none
  177. node_selector: "{{ openshift_service_catalog_nodeselector | default ({'openshift-infra': 'apiserver'}) }}"
  178. - name: Set Controller Manager deployment
  179. oc_obj:
  180. state: present
  181. namespace: "kube-service-catalog"
  182. kind: daemonset
  183. name: controller-manager
  184. files:
  185. - "{{ mktemp.stdout }}/controller_manager.yml"
  186. delete_after: yes
  187. - name: Set Controller Manager service
  188. oc_service:
  189. name: controller-manager
  190. namespace: kube-service-catalog
  191. state: present
  192. ports:
  193. - port: 6443
  194. protocol: TCP
  195. targetPort: 6443
  196. selector:
  197. app: controller-manager
  198. session_affinity: None
  199. service_type: ClusterIP
  200. - include: start_api_server.yml
  201. - name: Delete temp directory
  202. file:
  203. name: "{{ mktemp.stdout }}"
  204. state: absent
  205. changed_when: False