install.yml 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---
  2. # Fact setting
  3. - name: Set default image variables based on openshift_deployment_type
  4. include_vars: "{{ item }}"
  5. with_first_found:
  6. - "{{ openshift_deployment_type }}.yml"
  7. - "default_images.yml"
  8. - name: set template_service_broker facts
  9. set_fact:
  10. template_service_broker_prefix: "{{ template_service_broker_prefix | default(__template_service_broker_prefix) }}"
  11. template_service_broker_version: "{{ template_service_broker_version | default(__template_service_broker_version) }}"
  12. template_service_broker_image_name: "{{ template_service_broker_image_name | default(__template_service_broker_image_name) }}"
  13. - oc_project:
  14. name: openshift-template-service-broker
  15. state: present
  16. node_selector:
  17. - ""
  18. - command: mktemp -d /tmp/tsb-ansible-XXXXXX
  19. register: mktemp
  20. changed_when: False
  21. become: no
  22. - copy:
  23. src: "{{ __tsb_files_location }}/{{ item }}"
  24. dest: "{{ mktemp.stdout }}/{{ item }}"
  25. with_items:
  26. - "{{ __tsb_template_file }}"
  27. - "{{ __tsb_rbac_file }}"
  28. - "{{ __tsb_broker_file }}"
  29. - "{{ __tsb_config_file }}"
  30. - yedit:
  31. src: "{{ mktemp.stdout }}/{{ __tsb_config_file }}"
  32. key: templateNamespaces
  33. value: "{{ openshift_template_service_broker_namespaces }}"
  34. value_type: list
  35. - slurp:
  36. src: "{{ mktemp.stdout }}/{{ __tsb_config_file }}"
  37. register: config
  38. - name: Apply template file
  39. shell: >
  40. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __tsb_template_file }}"
  41. --param API_SERVER_CONFIG="{{ config['content'] | b64decode }}"
  42. --param IMAGE="{{ template_service_broker_prefix }}{{ template_service_broker_image_name }}:{{ template_service_broker_version }}"
  43. --param NODE_SELECTOR={{ template_service_broker_selector | to_json | quote }}
  44. | {{ openshift_client_binary }} apply -f -
  45. # reconcile with rbac
  46. - name: Reconcile with RBAC file
  47. shell: >
  48. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __tsb_rbac_file }}" | {{ openshift_client_binary }} auth reconcile -f -
  49. # Check that the TSB is running
  50. - name: Verify that TSB is running
  51. command: >
  52. curl -k https://apiserver.openshift-template-service-broker.svc/healthz
  53. args:
  54. # Disables the following warning:
  55. # Consider using get_url or uri module rather than running curl
  56. warn: no
  57. register: api_health
  58. until: api_health.stdout == 'ok'
  59. retries: 120
  60. delay: 1
  61. changed_when: false
  62. - set_fact:
  63. openshift_master_config_dir: "{{ openshift.common.config_base }}/master"
  64. when: openshift_master_config_dir is undefined
  65. - slurp:
  66. src: "{{ openshift_master_config_dir }}/service-signer.crt"
  67. register: __ca_bundle
  68. # Register with broker
  69. - name: Register TSB with broker
  70. shell: >
  71. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __tsb_broker_file }}" --param CA_BUNDLE="{{ __ca_bundle.content }}" | {{ openshift_client_binary }} apply -f -
  72. - file:
  73. state: absent
  74. name: "{{ mktemp.stdout }}"
  75. changed_when: False
  76. become: no