---
# main tasks for installing glusterfs
- name: add the glusterfs repo
  ansible.builtin.lineinfile:
    path: /etc/apt/sources.list.d/gluster.list
    state: present
    create: yes
    owner: root
    group: root
    mode: 644
    line: deb [arch=arm64] https://download.gluster.org/pub/gluster/glusterfs/6/6.9/Debian/bullseye/arm64/apt bullseye main

- name: Add an Apt signing key, uses whichever key is at the URL
  ansible.builtin.apt_key:
    url: https://download.gluster.org/pub/gluster/glusterfs/6/rsa.pub
    state: present

# install packages
- name: Ensure glusterfs server is installed.
  ansible.builtin.apt:
    name: "{{ item }}"
    update_cache: yes
    cache_valid_time: 3600
    state: present
  with_items:
    - glusterfs-server=6.9
    - xfsprogs
    - xfsdump

- name: Start service gluster, if not started
  block:
#    - name: start on home
#      ansible.builtin.service:
#        name: glusterd
#        state: started
#      when: "ansible_lsb.major_release >= '20'"

    - name: start on cubox-i
      ansible.builtin.service:
        name: glusterfs-server
        state: started
