---
# remove a volume
- name: "check for existing {{mounts.paths[item.name]}}/{{volumes.brick_folder}}/.glusterfs"
  stat:
    path: "{{mounts.paths[item.name]}}/{{volumes.brick_folder}}/.glusterfs"
  register: gluster_volume_config

- name: "Old gluster volume {{item.name}} needs to be removed"
  debug:
    var: gluster_volume_config.stat.exists

- name: remove old gluster volumes
  block:
    - name: remove volume
      gluster_volume:
        state: absent
        name: "{{item.name}}"
        #    rebalance: no
        #    replicas: false
        force: true
        cluster: "{{cluster}}"
      run_once: true
    - name: remove .glusterfs folder
      ansible.builtin.shell: "rm -rf {{mounts.paths[item.name]}}/.glusterfs"
  when: gluster_volume_config.stat.exists
