---
# install available glusterfs-server

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

- name: create systemd environment file
  ansible.builtin.template:
    src: systemd/environment.j2
    dest: "{{glusterd.envfile}}"
    owner: root
    group: root
    mode: '0644'
  notify:
    - restart glusterd

- name: enable systemd unit
  ansible.builtin.systemd:
    name: "{{ glusterd.unit }}"
    enabled: yes
  notify:
    - restart glusterd

- name: start glusterd
  ansible.builtin.systemd:
    name: "{{ glusterd.unit }}"
    state: started
