- name: Stat {{ quobyte_mount_point }}
  stat:
    path: "{{ quobyte_mount_point }}"
  register: tcs_mount
  failed_when: false
  changed_when: (tcs_mount.msg | default('')) == "Transport endpoint is not connected"

- name: Remount Broken {{ quobyte_mount_point }}
  become: true
  shell:  umount -l {{ quobyte_mount_point }} && mount {{ quobyte_mount_point }}
  when: (tcs_mount.msg | default('')) == "Transport endpoint is not connected"

- name: "{{ quobyte_mount_point }} Mount Point"
  become: true
  file:
    path: "{{ quobyte_mount_point }}"
    state: directory

- name: Remove Unneeded config files
  become: true
  file:
    path: "{{ item }}"
    state: absent
  loop:
    - /etc/quobyte/client-service.cfg
    - /etc/quobyte/clinte-service.env

- name: Mount SUN-TCS01
  become: true
  mount:
    src: "{{ quobyte_registry }}/"
    path: "{{ quobyte_mount_point }}"
    opts: defaults,_netdev,limit-nofile={{ quobyte_file_limit }},{{ quobyte_mount_options }}
    fstype: quobyte
    state: present
  notify: Remount Quobyte
  tags: mount
