---

- name: Create temp directory for doing work in on target
  command: mktemp -td openshift-prometheus-ansible-XXXXXX
  register: mktemp
  changed_when: False

- set_fact:
    tempdir: "{{ mktemp.stdout }}"

- name: Create templates subdirectory
  file:
    state: directory
    path: "{{ tempdir }}/{{ item }}"
    mode: 0755
  changed_when: False
  with_items:
    - templates

- include_tasks: install_prometheus.yaml
  when: openshift_prometheus_state == 'present'

- include_tasks: uninstall_prometheus.yaml
  when: openshift_prometheus_state == 'absent'

- include_tasks: install_node_exporter.yaml
  when: openshift_prometheus_node_exporter_install | default(true) | bool

- name: Delete temp directory
  file:
    name: "{{ tempdir }}"
    state: absent
  changed_when: False
