install.yml 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. ---
  2. - import_tasks: facts.yml
  3. - import_tasks: upgrade.yml
  4. when: openshift_upgrade_target is defined
  5. - include_tasks: generate_certs.yml
  6. # Deployment of ansible-service-broker starts here
  7. - name: create openshift-ansible-service-broker project
  8. oc_project:
  9. name: openshift-ansible-service-broker
  10. state: present
  11. node_selector:
  12. - ""
  13. - name: create ansible-service-broker serviceaccount
  14. oc_serviceaccount:
  15. name: asb
  16. namespace: openshift-ansible-service-broker
  17. state: present
  18. - name: create ansible-service-broker client serviceaccount
  19. oc_serviceaccount:
  20. name: asb-client
  21. namespace: openshift-ansible-service-broker
  22. state: present
  23. - name: Create asb-auth cluster role
  24. oc_clusterrole:
  25. state: present
  26. name: asb-auth
  27. rules:
  28. - apiGroups: [""]
  29. resources: ["namespaces"]
  30. verbs: ["create", "delete"]
  31. - apiGroups: ["authorization.openshift.io"]
  32. resources: ["subjectrulesreview"]
  33. verbs: ["create"]
  34. - apiGroups: ["authorization.k8s.io"]
  35. resources: ["subjectaccessreviews"]
  36. verbs: ["create"]
  37. - apiGroups: ["authentication.k8s.io"]
  38. resources: ["tokenreviews"]
  39. verbs: ["create"]
  40. - apiGroups: ["image.openshift.io", ""]
  41. resources: ["images"]
  42. verbs: ["get", "list"]
  43. - apiGroups: ["network.openshift.io"]
  44. resources: ["clusternetworks", "netnamespaces"]
  45. verbs: ["get"]
  46. - apiGroups: ["network.openshift.io"]
  47. resources: ["netnamespaces"]
  48. verbs: ["update"]
  49. - apiGroups: ["networking.k8s.io"]
  50. resources: ["networkpolicies"]
  51. verbs: ["create", "delete"]
  52. - apiGroups: ["automationbroker.io"]
  53. resources: ["bundles", "bundlebindings", "bundleinstances"]
  54. verbs: ["*"]
  55. - name: Create asb-access cluster role
  56. oc_clusterrole:
  57. state: present
  58. name: asb-access
  59. rules:
  60. - nonResourceURLs: ["/ansible-service-broker", "/ansible-service-broker/*"]
  61. verbs: ["get", "post", "put", "patch", "delete"]
  62. - name: Bind admin cluster-role to asb serviceaccount
  63. oc_adm_policy_user:
  64. state: present
  65. resource_kind: cluster-role
  66. resource_name: admin
  67. user: "system:serviceaccount:openshift-ansible-service-broker:asb"
  68. - name: Bind auth cluster role to asb service account
  69. oc_adm_policy_user:
  70. state: present
  71. resource_kind: cluster-role
  72. resource_name: asb-auth
  73. user: "system:serviceaccount:openshift-ansible-service-broker:asb"
  74. - name: Bind asb-access role to asb-client service account
  75. oc_adm_policy_user:
  76. state: present
  77. resource_kind: cluster-role
  78. resource_name: asb-access
  79. user: "system:serviceaccount:openshift-ansible-service-broker:asb-client"
  80. - name: create asb-client token secret
  81. oc_obj:
  82. name: asb-client
  83. namespace: openshift-ansible-service-broker
  84. state: present
  85. kind: Secret
  86. content:
  87. path: /tmp/asbclientsecretout
  88. data:
  89. apiVersion: v1
  90. kind: Secret
  91. metadata:
  92. name: asb-client
  93. namespace: openshift-ansible-service-broker
  94. annotations:
  95. kubernetes.io/service-account.name: asb-client
  96. type: kubernetes.io/service-account-token
  97. - oc_secret:
  98. state: list
  99. namespace: openshift-ansible-service-broker
  100. name: asb-client
  101. register: asb_client_secret
  102. - set_fact:
  103. service_ca_crt: "{{ asb_client_secret.results.results.0.data['service-ca.crt'] }}"
  104. - name: Create custom resource definitions for asb
  105. oc_obj:
  106. name: '{{ crd.metadata.name }}'
  107. kind: CustomResourceDefinition
  108. state: present
  109. content:
  110. path: /tmp/{{ crd.metadata.name }}
  111. data: '{{ crd }}'
  112. vars:
  113. crd: "{{ lookup('file', item) | from_yaml }}"
  114. with_fileglob:
  115. - 'files/*.automationbroker.io.yaml'
  116. - name: create ansible-service-broker service
  117. oc_service:
  118. name: asb
  119. namespace: openshift-ansible-service-broker
  120. labels:
  121. app: openshift-ansible-service-broker
  122. service: asb
  123. annotations:
  124. service.alpha.openshift.io/serving-cert-secret-name: asb-tls
  125. ports:
  126. - name: port-1338
  127. port: 1338
  128. targetPort: 1338
  129. protocol: TCP
  130. - name: port-1337
  131. port: 1337
  132. targetPort: 1337
  133. protocol: TCP
  134. selector:
  135. app: openshift-ansible-service-broker
  136. service: asb
  137. - name: create route for ansible-service-broker service
  138. oc_route:
  139. name: asb-1338
  140. namespace: openshift-ansible-service-broker
  141. state: present
  142. labels:
  143. app: openshift-ansible-service-broker
  144. service: asb
  145. service_name: asb
  146. port: 1338
  147. tls_termination: Reencrypt
  148. - name: create route for dashboard-redirector service
  149. oc_route:
  150. name: dr-1337
  151. namespace: openshift-ansible-service-broker
  152. state: present
  153. labels:
  154. app: openshift-ansible-service-broker
  155. service: asb
  156. service_name: asb
  157. port: 1337
  158. when: ansible_service_broker_enable_dashboard_redirector
  159. - name: Set Ansible Service Broker deployment config
  160. oc_obj:
  161. force: yes
  162. name: asb
  163. namespace: openshift-ansible-service-broker
  164. state: present
  165. kind: DeploymentConfig
  166. content:
  167. path: /tmp/dcout
  168. data: "{{ lookup('template', 'asb_dc.yaml.j2') | from_yaml }}"
  169. - name: set auth name and type facts if needed
  170. set_fact:
  171. ansible_service_broker_registry_auth_type: "secret"
  172. ansible_service_broker_registry_auth_name: "asb-registry-auth"
  173. when: ansible_service_broker_registry_user != "" and ansible_service_broker_registry_password != ""
  174. # TODO: saw a oc_configmap in the library, but didn't understand how to get it to do the following:
  175. - name: Create config map for ansible-service-broker
  176. oc_obj:
  177. name: broker-config
  178. namespace: openshift-ansible-service-broker
  179. state: present
  180. kind: ConfigMap
  181. content:
  182. path: /tmp/cmout
  183. data: "{{ lookup('template', 'configmap.yaml.j2') | from_yaml }}"
  184. - oc_secret:
  185. name: asb-registry-auth
  186. namespace: openshift-ansible-service-broker
  187. state: present
  188. contents:
  189. - path: username
  190. data: "{{ ansible_service_broker_registry_user }}"
  191. - path: password
  192. data: "{{ ansible_service_broker_registry_password }}"
  193. when: ansible_service_broker_registry_user != "" and ansible_service_broker_registry_password != ""
  194. - name: Create the Broker resource in the catalog
  195. oc_obj:
  196. name: ansible-service-broker
  197. state: present
  198. kind: ClusterServiceBroker
  199. content:
  200. path: /tmp/brokerout
  201. data:
  202. apiVersion: servicecatalog.k8s.io/v1beta1
  203. kind: ClusterServiceBroker
  204. metadata:
  205. name: ansible-service-broker
  206. spec:
  207. url: https://asb.openshift-ansible-service-broker.svc:1338/ansible-service-broker
  208. authInfo:
  209. bearer:
  210. secretRef:
  211. name: asb-client
  212. namespace: openshift-ansible-service-broker
  213. kind: Secret
  214. caBundle: "{{ service_ca_crt }}"