---
- fail:
    msg: Only one Fluentd nodeselector key pair should be provided
  when: openshift_logging_fluentd_nodeselector.keys() | count > 1

- name: Create temp directory for doing work in
  command: mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  register: mktemp
  changed_when: False
  check_mode: no
  tags: logging_init

- debug: msg="Created temp dir {{mktemp.stdout}}"

- name: Create local temp directory for doing work in
  local_action: command mktemp -d /tmp/openshift-logging-ansible-XXXXXX
  register: local_tmp
  changed_when: False
  check_mode: no
  vars:
    ansible_become: false

- include_tasks: discover_namespace.yaml

- include_tasks: install_logging.yaml
  when:
  - openshift_logging_install_logging | default(false) | bool

- include_tasks: delete_logging.yaml
  when:
  - not openshift_logging_install_logging | default(false) | bool

- name: Cleaning up local temp dir
  local_action: file path="{{ local_tmp.stdout }}" state=absent
  tags: logging_cleanup
  changed_when: False
  become: false

- name: Cleaning up temp dir
  file:
    path: "{{ mktemp.stdout }}"
    state: absent
  tags: logging_cleanup
  changed_when: False
