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

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

- include_tasks: glusterfs_config.yml
  when:
  - groups.glusterfs | default([]) | count > 0

- include_tasks: glusterfs_registry.yml
  when: >
    groups.glusterfs_registry | default([]) | count > 0
    or (openshift_hosted_registry_storage_kind | default(none) == 'glusterfs')
    or (openshift_hosted_registry_storage_glusterfs_swap | default(False))

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