---
- name: Create temp directory for doing work in
  command: mktemp -td openshift-provisioners-ansible-XXXXXX
  register: mktemp
  changed_when: False
  check_mode: no

- name: Copy the admin client config(s)
  command: >
    cp {{ openshift.common.config_base}}/master/admin.kubeconfig {{ mktemp.stdout }}/admin.kubeconfig
  changed_when: False
  check_mode: no
  tags: provisioners_init

- name: Set eventrouter image facts
  set_fact:
    openshift_provisioners_image_prefix: "{{ openshift_provisioners_image_prefix | default(openshift_provisioners_image_prefix_dict[openshift_deployment_type]) }}"
    openshift_provisioners_image_version: "{{ openshift_provisioners_image_version | default(openshift_provisioners_image_version_dict[openshift_deployment_type]) }}"

- include_tasks: install_provisioners.yaml
  when: openshift_provisioners_install_provisioners | default(false) | bool

- include_tasks: uninstall_provisioners.yaml
  when: not openshift_provisioners_install_provisioners | default(false) | bool

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