update_console_config.yml 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. ---
  2. # This task updates asset config values in the webconsole-config config map in
  3. # the openshift-web-console namespace. The values to set are pased in the
  4. # variable `console_config_edits`, which is an array of objects with `key` and
  5. # `value` properties in the same format as `yedit` module `edits`. Only
  6. # properties passed are updated. The separator for nested properties is `#`.
  7. #
  8. # Note that this triggers a redeployment on the console and a brief downtime
  9. # since it uses a `Recreate` strategy.
  10. #
  11. # Example usage:
  12. #
  13. # - include_role:
  14. # name: openshift_web_console
  15. # tasks_from: update_console_config.yml
  16. # vars:
  17. # console_config_edits:
  18. # - key: clusterInfo#loggingPublicURL
  19. # value: "https://{{ openshift_logging_kibana_hostname }}"
  20. # when: openshift_web_console_install | default(true) | bool
  21. - name: Read the existing web console config map
  22. oc_configmap:
  23. namespace: openshift-web-console
  24. name: webconsole-config
  25. state: list
  26. register: webconsole_config_map
  27. - set_fact:
  28. existing_config_map_data: "{{ webconsole_config_map.results.results[0].data | default({}) }}"
  29. - when: existing_config_map_data['webconsole-config.yaml'] is defined
  30. block:
  31. - name: Make temp directory
  32. command: mktemp -d /tmp/console-ansible-XXXXXX
  33. register: mktemp_console
  34. changed_when: False
  35. - name: Copy the existing web console config to temp directory
  36. copy:
  37. content: "{{ existing_config_map_data['webconsole-config.yaml'] }}"
  38. dest: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  39. - name: Change web console config properties
  40. yedit:
  41. src: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  42. edits: "{{console_config_edits}}"
  43. separator: '#'
  44. state: present
  45. - name: Update web console config map
  46. oc_configmap:
  47. namespace: openshift-web-console
  48. name: webconsole-config
  49. state: present
  50. from_file:
  51. webconsole-config.yaml: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  52. register: update_console_config_map
  53. - name: Remove temp directory
  54. file:
  55. state: absent
  56. name: "{{ mktemp_console.stdout }}"
  57. changed_when: False
  58. - include_tasks: rollout_console.yml
  59. when: update_console_config_map.changed | bool