---
# 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
    regexp: deb-src
    line: deb-src https://download.gluster.org/pub/gluster/glusterfs/LATEST/Debian/bullseye/amd64/apt bullseye main

- name: make a build dir
  ansible.builtin.file:
    path: src/debian
    state: directory
    mode: '0755'

- 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

- name: Ensure build tools are installed.
  ansible.builtin.apt:
    name: "{{ item }}"
    state: present
  with_items:
    - dpkg-dev

- name: Ensure build deps are installed.
  ansible.builtin.apt:
    name: "{{ item }}"
    state: build-dep
  with_items:
    - glusterfs-server



# 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
