install.yml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. ---
  2. # Fact setting and validations
  3. - name: Set default image variables based on deployment type
  4. include_vars: "{{ item }}"
  5. with_first_found:
  6. - "{{ openshift_deployment_type | default(deployment_type) }}.yml"
  7. - "default_images.yml"
  8. - name: set ansible_service_broker facts
  9. set_fact:
  10. ansible_service_broker_image_prefix: "{{ ansible_service_broker_image_prefix | default(__ansible_service_broker_image_prefix) }}"
  11. ansible_service_broker_image_tag: "{{ ansible_service_broker_image_tag | default(__ansible_service_broker_image_tag) }}"
  12. ansible_service_broker_etcd_image_prefix: "{{ ansible_service_broker_etcd_image_prefix | default(__ansible_service_broker_etcd_image_prefix) }}"
  13. ansible_service_broker_etcd_image_tag: "{{ ansible_service_broker_etcd_image_tag | default(__ansible_service_broker_etcd_image_tag) }}"
  14. ansible_service_broker_registry_type: "{{ ansible_service_broker_registry_type | default(__ansible_service_broker_registry_type) }}"
  15. ansible_service_broker_registry_url: "{{ ansible_service_broker_registry_url | default(__ansible_service_broker_registry_url) }}"
  16. ansible_service_broker_registry_user: "{{ ansible_service_broker_registry_user | default(__ansible_service_broker_registry_user) }}"
  17. ansible_service_broker_registry_password: "{{ ansible_service_broker_registry_password | default(__ansible_service_broker_registry_password) }}"
  18. ansible_service_broker_registry_organization: "{{ ansible_service_broker_registry_organization | default(__ansible_service_broker_registry_organization) }}"
  19. - name: set ansible-service-broker image facts using set prefix and tag
  20. set_fact:
  21. ansible_service_broker_image: "{{ ansible_service_broker_image_prefix }}ansible-service-broker:{{ ansible_service_broker_image_tag }}"
  22. ansible_service_broker_etcd_image: "{{ ansible_service_broker_etcd_image_prefix }}ansible-service-broker:{{ ansible_service_broker_etcd_image_tag }}"
  23. - include: validate_facts.yml
  24. # Deployment of ansible-service-broker starts here
  25. - name: create openshift-ansible-service-broker project
  26. oc_project:
  27. name: openshift-ansible-service-broker
  28. state: present
  29. - name: create ansible-service-broker serviceaccount
  30. oc_serviceaccount:
  31. name: asb
  32. namespace: openshift-ansible-service-broker
  33. state: present
  34. - name: create ansible-service-broker service
  35. oc_service:
  36. name: asb
  37. namespace: openshift-ansible-service-broker
  38. state: present
  39. labels:
  40. app: ansible-service-broker
  41. service: asb
  42. ports:
  43. - name: port-1338
  44. port: 1338
  45. selector:
  46. app: ansible-service-broker
  47. service: asb
  48. - name: create etcd service
  49. oc_service:
  50. name: etcd
  51. namespace: openshift-ansible-service-broker
  52. state: present
  53. ports:
  54. - name: etcd-advertise
  55. port: 2379
  56. selector:
  57. app: ansible-service-broker
  58. service: etcd
  59. - name: create route for ansible-service-broker service
  60. oc_route:
  61. name: asb-1338
  62. namespace: openshift-ansible-service-broker
  63. state: present
  64. service_name: asb
  65. port: 1338
  66. register: asb_route_out
  67. - name: get ansible-service-broker route name
  68. set_fact:
  69. ansible_service_broker_route: "{{ asb_route_out.results.results[0].spec.host }}"
  70. - name: create persistent volume claim for etcd
  71. oc_obj:
  72. name: etcd
  73. namespace: openshift-ansible-service-broker
  74. state: present
  75. kind: PersistentVolumeClaim
  76. content:
  77. path: /tmp/dcout
  78. data:
  79. apiVersion: v1
  80. kind: PersistentVolumeClaim
  81. metadata:
  82. name: etcd
  83. namespace: openshift-ansible-service-broker
  84. spec:
  85. accessModes:
  86. - ReadWriteOnce
  87. resources:
  88. requests:
  89. storage: 1Gi
  90. - name: create etcd deployment
  91. oc_obj:
  92. name: etcd
  93. namespace: openshift-ansible-service-broker
  94. state: present
  95. kind: Deployment
  96. content:
  97. path: /tmp/dcout
  98. data:
  99. apiVersion: extensions/v1beta1
  100. kind: Deployment
  101. metadata:
  102. name: etcd
  103. namespace: openshift-ansible-service-broker
  104. labels:
  105. app: ansible-service-broker
  106. service: etcd
  107. spec:
  108. selector:
  109. matchLabels:
  110. app: ansible-service-broker
  111. service: etcd
  112. strategy:
  113. type: RollingUpdate
  114. rollingUpdate:
  115. maxSurge: 1
  116. maxUnavailable: 1
  117. replicas: 1
  118. template:
  119. metadata:
  120. labels:
  121. app: ansible-service-broker
  122. service: etcd
  123. spec:
  124. restartPolicy: Always
  125. containers:
  126. - image: "{{ ansible_service_broker_etcd_image }}"
  127. name: etcd
  128. imagePullPolicy: IfNotPresent
  129. terminationMessagePath: /tmp/termination-log
  130. workingDir: /etcd
  131. args:
  132. - ./etcd
  133. - --data-dir=/data
  134. - "--listen-client-urls=http://0.0.0.0:2379"
  135. - "--advertise-client-urls=http://0.0.0.0:2379"
  136. ports:
  137. - containerPort: 2379
  138. protocol: TCP
  139. env:
  140. - name: ETCDCTL_API
  141. value: "3"
  142. volumeMounts:
  143. - mountPath: /data
  144. name: etcd
  145. volumes:
  146. - name: etcd
  147. persistentVolumeClaim:
  148. claimName: etcd
  149. - name: create ansible-service-broker deployment
  150. oc_obj:
  151. name: asb
  152. namespace: openshift-ansible-service-broker
  153. state: present
  154. kind: Deployment
  155. content:
  156. path: /tmp/dcout
  157. data:
  158. apiVersion: extensions/v1beta1
  159. kind: Deployment
  160. metadata:
  161. name: asb
  162. namespace: openshift-ansible-service-broker
  163. labels:
  164. app: openshift-ansible-service-broker
  165. service: asb
  166. spec:
  167. strategy:
  168. type: Recreate
  169. replicas: 1
  170. template:
  171. metadata:
  172. labels:
  173. app: openshift-ansible-service-broker
  174. service: asb
  175. spec:
  176. serviceAccount: asb
  177. restartPolicy: Always
  178. containers:
  179. - image: "{{ ansible_service_broker_image }}"
  180. name: asb
  181. imagePullPolicy: IfNotPresent
  182. volumeMounts:
  183. - name: config-volume
  184. mountPath: /etc/ansible-service-broker
  185. ports:
  186. - containerPort: 1338
  187. protocol: TCP
  188. args:
  189. - -c
  190. - /etc/ansible-service-broker/config.yaml
  191. terminationMessagePath: /tmp/termination-log
  192. volumes:
  193. - name: config-volume
  194. configMap:
  195. name: broker-config
  196. items:
  197. - key: broker-config
  198. path: config.yaml
  199. # TODO: saw a oc_configmap in the library, but didn't understand how to get it to do the following:
  200. - name: Create config map for ansible-service-broker
  201. oc_obj:
  202. name: broker-config
  203. namespace: openshift-ansible-service-broker
  204. state: present
  205. kind: ConfigMap
  206. content:
  207. path: /tmp/cmout
  208. data:
  209. apiVersion: v1
  210. kind: ConfigMap
  211. metadata:
  212. name: broker-config
  213. namespace: openshift-ansible-service-broker
  214. labels:
  215. app: ansible-service-broker
  216. data:
  217. broker-config: |
  218. registry:
  219. name: "{{ ansible_service_broker_registry_type }}"
  220. url: "{{ ansible_service_broker_registry_url }}"
  221. user: "{{ ansible_service_broker_registry_user }}"
  222. pass: "{{ ansible_service_broker_registry_password }}"
  223. org: "{{ ansible_service_broker_registry_organization }}"
  224. dao:
  225. etcd_host: etcd
  226. etcd_port: 2379
  227. log:
  228. logfile: /var/log/ansible-service-broker/asb.log
  229. stdout: true
  230. level: "{{ ansible_service_broker_log_level }}"
  231. color: true
  232. openshift: {}
  233. broker:
  234. devbroker: false
  235. launchapbonbind: "{{ ansible_service_broker_launch_apb_on_bind }}"
  236. - name: Create the Broker resource in the catalog
  237. oc_obj:
  238. name: ansible-service-broker
  239. state: present
  240. kind: Broker
  241. content:
  242. path: /tmp/brokerout
  243. data:
  244. apiVersion: servicecatalog.k8s.io/v1alpha1
  245. kind: Broker
  246. metadata:
  247. name: ansible-service-broker
  248. spec:
  249. url: http://{{ ansible_service_broker_route }}