install.yml 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. - set_fact:
  39. # Must have a trailing slash
  40. console_picker_developer_console_public_url: "{{ openshift.master.public_console_url }}/"
  41. when: (openshift_web_console_enable_context_selector | default(true) | bool) and (openshift_web_console_install | default(true) | bool)
  42. - set_fact: console_cert={{ lookup('file', openshift_console_cert) }}
  43. when: openshift_console_cert is exists
  44. changed_when: false
  45. - set_fact: console_key={{ lookup('file', openshift_console_key) }}
  46. when: openshift_console_key is exists
  47. changed_when: false
  48. - set_fact: console_ca_cert={{ lookup('file', openshift_console_ca) }}
  49. when: openshift_console_ca is exists
  50. changed_when: false
  51. # Generate a new config when a config map is not defined.
  52. - name: Set web console config properties from inventory variables
  53. yedit:
  54. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  55. edits:
  56. - key: clusterInfo#consoleBaseAddress
  57. value: "https://{{ openshift_console_hostname }}"
  58. - key: clusterInfo#consoleBasePath
  59. value: "{{ openshift_console_base_path | default('') }}"
  60. - key: clusterInfo#masterPublicURL
  61. value: "{{ openshift.master.public_api_url }}"
  62. - key: auth#oauthEndpointCAFile
  63. value: "{{ openshift_console_auth_ca_file }}"
  64. - key: auth#logoutRedirect
  65. value: "{{ openshift.master.logout_url | default('') }}"
  66. - key: customization#branding
  67. value: "{{ openshift_console_branding }}"
  68. - key: customization#documentationBaseURL
  69. value: "{{ openshift_console_documentation_base_url }}"
  70. separator: '#'
  71. state: present
  72. when: existing_config_map_data['console-config.yaml'] is not defined
  73. # Add the developer console URL to the console picker on upgrade, even if there is an existing config.
  74. - name: Add context selector URL
  75. yedit:
  76. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  77. edits:
  78. - key: clusterInfo#developerConsolePublicURL
  79. value: "{{ console_picker_developer_console_public_url | default('') }}"
  80. separator: '#'
  81. state: present
  82. - slurp:
  83. src: "{{ mktemp.stdout }}/{{ __console_config_file }}"
  84. register: updated_console_config
  85. - name: Apply the console template file
  86. shell: >
  87. {{ openshift_client_binary }} process -f "{{ mktemp.stdout }}/{{ __console_template_file }}"
  88. --param IMAGE="{{ openshift_console_image_name }}"
  89. --param NODE_SELECTOR={{ openshift_console_nodeselector | to_json | quote }}
  90. --param SERVER_CONFIG="{{ updated_console_config['content'] | b64decode }}"
  91. --param REPLICA_COUNT="{{ openshift_console_replica_count }}"
  92. --param CONSOLE_HOSTNAME="{{ openshift_console_hostname }}"
  93. --param TLS_CERT="{{ console_cert | default('') }}"
  94. --param TLS_KEY="{{ console_key | default('') }}"
  95. --param TLS_CA_CERT="{{ console_ca_cert | default('') }}"
  96. --config={{ mktemp.stdout }}/admin.kubeconfig
  97. | {{ openshift_client_binary }} apply --config={{ mktemp.stdout }}/admin.kubeconfig -f -
  98. - name: Remove temp directory
  99. file:
  100. state: absent
  101. name: "{{ mktemp.stdout }}"
  102. changed_when: False
  103. - include_tasks: start.yml