update_console_config.yml 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 web console config map
  22. oc_configmap:
  23. namespace: openshift-web-console
  24. name: webconsole-config
  25. state: list
  26. register: webconsole_config
  27. - name: Make temp directory
  28. command: mktemp -d /tmp/console-ansible-XXXXXX
  29. register: mktemp_console
  30. changed_when: False
  31. - name: Copy web console config to temp file
  32. copy:
  33. content: "{{webconsole_config.results.results[0].data['webconsole-config.yaml']}}"
  34. dest: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  35. - name: Change web console config properties
  36. yedit:
  37. src: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  38. edits: "{{console_config_edits}}"
  39. separator: '#'
  40. state: present
  41. - name: Update web console config map
  42. oc_configmap:
  43. namespace: openshift-web-console
  44. name: webconsole-config
  45. state: present
  46. from_file:
  47. webconsole-config.yaml: "{{ mktemp_console.stdout }}/webconsole-config.yaml"
  48. - name: Remove temp directory
  49. file:
  50. state: absent
  51. name: "{{ mktemp_console.stdout }}"
  52. changed_when: False
  53. # TODO: Only rollout if config has changed.
  54. - include_tasks: rollout_console.yml