main.yaml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. ---
  2. - fail:
  3. msg: Only one Fluentd nodeselector key pair should be provided
  4. when: openshift_logging_fluentd_nodeselector.keys() | count > 1
  5. - name: Create temp directory for doing work in
  6. command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  7. register: mktemp
  8. changed_when: False
  9. check_mode: no
  10. tags: logging_init
  11. - debug: msg="Created temp dir {{mktemp.stdout}}"
  12. - name: Create local temp directory for doing work in
  13. local_action: command mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  14. register: local_tmp
  15. changed_when: False
  16. check_mode: no
  17. vars:
  18. ansible_become: false
  19. - oc_obj:
  20. state: list
  21. kind: dc
  22. all_namespaces: true
  23. selector: "logging-infra,provider=openshift,component!=eventrouter"
  24. register: _logging_dcs
  25. - set_fact:
  26. _current_logging_namespace: "{{ _logging_dcs.results.results[0]['items'] | map(attribute='metadata.namespace') | list | unique | join(' ') }}"
  27. when:
  28. - _logging_dcs is defined
  29. - _logging_dcs.results | count > 0
  30. - _logging_dcs.results.results | count > 0
  31. - when:
  32. - logging_disable_namespace_check | default(false) | bool
  33. - _logging_namespace is defined
  34. - _current_logging_namespace.split(" ") | count > 0
  35. - _current_logging_namespace != ''
  36. - _logging_namespace != _current_logging_namespace
  37. block:
  38. - name: Set Logging message about installing in multiple namespaces
  39. run_once: true
  40. set_stats:
  41. data:
  42. installer_phase_logging:
  43. message: "Aggregated logging installed in multiple namespaces: \
  44. current namespace(s): {{ _current_logging_namespace }} \
  45. specified namespace: {{ _logging_namespace | default(_current_logging_namespace) }}"
  46. - debug:
  47. msg: "Aggregated logging installed in multiple namespaces: \
  48. current namespace(s): {{ _current_logging_namespace }} \
  49. specified namespace: {{ _logging_namespace | default(_current_logging_namespace) }}"
  50. - when: not logging_disable_namespace_check | default(false) | bool
  51. block:
  52. - assert:
  53. that:
  54. - _current_logging_namespace.split(" ") | count <= 1
  55. - not _logging_namespace is defined or not _current_logging_namespace or _logging_namespace == _current_logging_namespace
  56. msg: "Configuring aggregated logging in multiple namespaces is not supported: \
  57. current namespace(s): {{ _current_logging_namespace }} \
  58. specified namespace: {{ _logging_namespace | default(_current_logging_namespace) }}"
  59. - debug:
  60. msg: "Using the namespace '{{ _current_logging_namespace }}' which has an existing deployment"
  61. when:
  62. - _current_logging_namespace is defined
  63. - _current_logging_namespace != ''
  64. - set_fact:
  65. _logging_namespace: "{{ _current_logging_namespace if _current_logging_namespace else _logging_namespace | default('openshift-logging') }}"
  66. - when:
  67. - logging_disable_namespace_check | default(false) | bool
  68. - not _logging_namespace is defined
  69. block:
  70. - assert:
  71. that:
  72. - _current_logging_namespace.split(" ") | count == 1
  73. msg: "Multiple aggregated logging installations found in [{{ _current_logging_namespace }}], please specify which to use with _logging_namespace"
  74. - set_fact:
  75. _logging_namespace: "{{ _current_logging_namespace }}"
  76. - set_fact:
  77. openshift_logging_namespace: "{{ _logging_namespace if _logging_namespace else 'openshift-logging' }}"
  78. - include_tasks: install_logging.yaml
  79. when:
  80. - openshift_logging_install_logging | default(false) | bool
  81. - include_tasks: delete_logging.yaml
  82. when:
  83. - not openshift_logging_install_logging | default(false) | bool
  84. - name: Cleaning up local temp dir
  85. local_action: file path="{{ local_tmp.stdout }}" state=absent
  86. tags: logging_cleanup
  87. changed_when: False
  88. become: false
  89. - name: Cleaning up temp dir
  90. file:
  91. path: "{{ mktemp.stdout }}"
  92. state: absent
  93. tags: logging_cleanup
  94. changed_when: False
  95. become: false