install.yml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---
  2. - name: Ensure openshift-console project exists
  3. oc_project:
  4. name: openshift-console
  5. state: present
  6. node_selector:
  7. - ""
  8. - name: Make temp directory for console templates
  9. command: mktemp -d /tmp/console-ansible-XXXXXX
  10. register: mktemp
  11. changed_when: False
  12. - name: Copy admin client config
  13. command: >
  14. cp {{ openshift.common.config_base }}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  15. changed_when: false
  16. - name: Copy console templates to temp directory
  17. copy:
  18. src: "{{ item }}"
  19. dest: "{{ mktemp.stdout }}/{{ item }}"
  20. with_items:
  21. - "{{ __console_template_file }}"
  22. - "{{ __console_config_file }}"
  23. # Check if an existing console-config config map exists. If so, use those
  24. # contents so we don't overwrite changes.
  25. - name: Read the existing console config map
  26. oc_configmap:
  27. namespace: openshift-console
  28. name: console-config
  29. state: list
  30. register: console_config_map
  31. - set_fact:
  32. existing_config_map_data: "{{ console_config_map.results.results[0].data | default({}) }}"
  33. - name: Copy the existing web console config to temp directory
  34. copy:
  35. content: "{{ existing_config_map_data['console-config.yaml'] }}"
  36. dest: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  37. when: existing_config_map_data['console-config.yaml'] is defined
  38. # Generate a new config when a config map is not defined.
  39. - name: Set web console config properties from inventory variables
  40. yedit:
  41. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  42. edits:
  43. - key: clusterInfo#consoleBaseAddress
  44. value: "https://{{ openshift_console_hostname }}"
  45. - key: clusterInfo#consoleBasePath
  46. value: "{{ openshift_console_base_path | default('') }}"
  47. - key: clusterInfo#masterPublicURL
  48. value: "{{ openshift.master.public_api_url }}"
  49. - key: auth#oauthEndpointCAFile
  50. value: "{{ openshift_console_auth_ca_file }}"
  51. - key: auth#logoutRedirect
  52. value: "{{ openshift.master.logout_url | default('') }}"
  53. - key: customization#logoImageName
  54. value: "{{ openshift_console_logo_image_name }}"
  55. - key: customization#documentationBaseURL
  56. value: "{{ openshift_console_documentation_base_url }}"
  57. separator: '#'
  58. state: present
  59. when: existing_config_map_data['console-config.yaml'] is not defined
  60. - slurp:
  61. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  62. register: updated_console_config
  63. - name: Apply the console template file
  64. shell: >
  65. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __console_template_file }}"
  66. --param IMAGE="{{ openshift_console_image_name }}"
  67. --param NODE_SELECTOR={{ openshift_console_nodeselector | to_json | quote }}
  68. --param SERVER_CONFIG="{{ updated_console_config['content'] | b64decode }}"
  69. --param REPLICA_COUNT="{{ openshift_console_replica_count }}"
  70. --param CONSOLE_HOSTNAME="{{ openshift_console_hostname }}"
  71. --config={{ mktemp.stdout }}/admin.kubeconfig
  72. | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  73. - name: Remove temp directory
  74. file:
  75. state: absent
  76. name: "{{ mktemp.stdout }}"
  77. changed_when: False
  78. - include_tasks: start.yml