---

- name: Set default image variables based on openshift_deployment_type
  include_vars: "{{ item }}"
  with_first_found:
    - "{{ openshift_deployment_type }}.yml"
    - "default_images.yml"

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

- include_tasks: facts.yaml
- include_tasks: install_grafana.yaml
  when: grafana_state == 'present'

- include_tasks: uninstall_grafana.yaml
  when: grafana_state == 'absent'

- name: Delete temp directory
  file:
    name: "{{ mktemp.stdout }}"
    state: absent
  changed_when: False
  check_mode: no
