install.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ---
  2. # Fact setting
  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 openshift_web_console facts
  9. set_fact:
  10. openshift_web_console_prefix: "{{ openshift_web_console_prefix | default(__openshift_web_console_prefix) }}"
  11. openshift_web_console_version: "{{ openshift_web_console_version | default(__openshift_web_console_version) }}"
  12. openshift_web_console_image_name: "{{ openshift_web_console_image_name | default(__openshift_web_console_image_name) }}"
  13. # Default the replica count to the number of masters.
  14. openshift_web_console_replica_count: "{{ openshift_web_console_replica_count | default(groups.oo_masters_to_config | length) }}"
  15. - name: Ensure openshift-web-console project exists
  16. oc_project:
  17. name: openshift-web-console
  18. state: present
  19. node_selector:
  20. - ""
  21. - name: Make temp directory for the web console config files
  22. command: mktemp -d /tmp/console-ansible-XXXXXX
  23. register: mktemp
  24. changed_when: False
  25. - name: Copy admin client config
  26. command: >
  27. cp {{ openshift.common.config_base }}/master//admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  28. changed_when: false
  29. - name: Copy the web console config template to temp directory
  30. copy:
  31. src: "{{ __console_files_location }}/{{ item }}"
  32. dest: "{{ mktemp.stdout }}/{{ item }}"
  33. with_items:
  34. - "{{ __console_template_file }}"
  35. - "{{ __console_rbac_file }}"
  36. - "{{ __console_config_file }}"
  37. - name: Update the web console config properties
  38. yedit:
  39. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  40. edits:
  41. - key: clusterInfo#consolePublicURL
  42. # Must have a trailing slash
  43. value: "{{ openshift.master.public_console_url }}/"
  44. - key: clusterInfo#masterPublicURL
  45. value: "{{ openshift.master.public_api_url }}"
  46. - key: clusterInfo#logoutPublicURL
  47. value: "{{ openshift.master.logout_url | default('') }}"
  48. - key: features#inactivityTimeoutMinutes
  49. value: "{{ openshift_web_console_inactivity_timeout_minutes | default(0) }}"
  50. - key: extensions#scriptURLs
  51. value: "{{ openshift_web_console_extension_script_urls | default([]) }}"
  52. - key: extensions#stylesheetURLs
  53. value: "{{ openshift_web_console_extension_stylesheet_urls | default([]) }}"
  54. - key: extensions#properties
  55. value: "{{ openshift_web_console_extension_properties | default({}) }}"
  56. separator: '#'
  57. state: present
  58. - slurp:
  59. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  60. register: config
  61. - name: Reconcile with the web console RBAC file
  62. shell: >
  63. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __console_rbac_file }}" --config={{ mktemp.stdout }}/admin.kubeconfig
  64. | {{ openshift_client_binary }} auth reconcile --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  65. - name: Apply the web console template file
  66. shell: >
  67. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __console_template_file }}"
  68. --param API_SERVER_CONFIG="{{ config['content'] | b64decode }}"
  69. --param IMAGE="{{ openshift_web_console_prefix }}{{ openshift_web_console_image_name }}:{{ openshift_web_console_version }}"
  70. --param NODE_SELECTOR={{ openshift_web_console_nodeselector | to_json | quote }}
  71. --param REPLICA_COUNT="{{ openshift_web_console_replica_count }}"
  72. --config={{ mktemp.stdout }}/admin.kubeconfig
  73. | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  74. - name: Verify that the web console is running
  75. command: >
  76. curl -k https://webconsole.openshift-web-console.svc/healthz
  77. args:
  78. # Disables the following warning:
  79. # Consider using get_url or uri module rather than running curl
  80. warn: no
  81. register: console_health
  82. until: console_health.stdout == 'ok'
  83. retries: 120
  84. delay: 1
  85. changed_when: false
  86. - name: Remove temp directory
  87. file:
  88. state: absent
  89. name: "{{ mktemp.stdout }}"
  90. changed_when: False