summaryrefslogtreecommitdiffstats
path: root/roles/openshift_web_console/tasks/update_console_config.yml
blob: 967222ea46e7a57d26c0104836ed1180662e4acc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
# This task updates asset config values in the webconsole-config config map in
# the openshift-web-console namespace. The values to set are pased in the
# variable `console_config_edits`, which is an array of objects with `key` and
# `value` properties in the same format as `yedit` module `edits`. Only
# properties passed are updated. The separator for nested properties is `#`.
#
# Note that this triggers a redeployment on the console and a brief downtime
# since it uses a `Recreate` strategy.
#
# Example usage:
#
# - include_role:
#     name: openshift_web_console
#     tasks_from: update_console_config.yml
#   vars:
#     console_config_edits:
#       - key: clusterInfo#loggingPublicURL
#         value: "https://{{ openshift_logging_kibana_hostname }}"
#   when: openshift_web_console_install | default(true) | bool

- name: Read the existing web console config map
  oc_configmap:
    namespace: openshift-web-console
    name: webconsole-config
    state: list
  register: webconsole_config_map

- set_fact:
    existing_config_map_data: "{{ webconsole_config_map.results.results[0].data | default({}) }}"

- when: existing_config_map_data['webconsole-config.yaml'] is defined
  block:
  - name: Make temp directory
    command: mktemp -d /tmp/console-ansible-XXXXXX
    register: mktemp_console
    changed_when: False

  - name: Copy the existing web console config to temp directory
    copy:
      content: "{{ existing_config_map_data['webconsole-config.yaml'] }}"
      dest: "{{ mktemp_console.stdout }}/webconsole-config.yaml"

  - name: Change web console config properties
    yedit:
      src: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
      edits: "{{console_config_edits}}"
      separator: '#'
      state: present

  - name: Update web console config map
    oc_configmap:
      namespace: openshift-web-console
      name: webconsole-config
      state: present
      from_file:
        webconsole-config.yaml: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
    register: update_console_config_map

  - name: Remove temp directory
    file:
      state: absent
      name: "{{ mktemp_console.stdout }}"
    changed_when: False

  - include_tasks: rollout_console.yml
    when: update_console_config_map.changed | bool