update_console_config.yml 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. # There's currently no command to trigger a rollout for a k8s deployment
  55. # without changing the pod spec. Add an annotation to force a rollout after
  56. # the config map has been edited.
  57. - name: Rollout updated web console deployment
  58. oc_edit:
  59. kind: deployments
  60. name: webconsole
  61. namespace: openshift-web-console
  62. separator: '#'
  63. content:
  64. spec#template#metadata#annotations#installer-triggered-rollout: "{{ ansible_date_time.iso8601_micro }}"