50 lines
1.4 KiB
YAML
50 lines
1.4 KiB
YAML
# Referenced and documented by https://wiki.k-space.ee/en/hosting/storage#zrepl
|
|
|
|
- name: zrepl
|
|
hosts: nasgroup
|
|
tasks:
|
|
- name: 'apt: zrepl gpg'
|
|
ansible.builtin.get_url:
|
|
url: 'https://zrepl.cschwarz.com/apt/apt-key.asc'
|
|
dest: /usr/share/keyrings/zrepl.asc
|
|
- name: 'apt: zrepl repo'
|
|
apt_repository:
|
|
repo: 'deb [arch=amd64 signed-by=/usr/share/keyrings/zrepl.asc] https://zrepl.cschwarz.com/apt/debian bookworm main'
|
|
- name: 'apt: ensure packages'
|
|
apt:
|
|
state: latest
|
|
pkg: zrepl
|
|
|
|
- name: 'zrepl: ensure config'
|
|
ansible.builtin.template:
|
|
src: "zrepl_{{ansible_hostname}}.yml.j2"
|
|
dest: /etc/zrepl/zrepl.yml
|
|
mode: 600
|
|
register: zreplconf
|
|
- name: 'zrepl: restart service after config change'
|
|
when: zreplconf.changed
|
|
service:
|
|
state: restarted
|
|
enabled: true
|
|
name: zrepl
|
|
- name: 'zrepl: ensure service'
|
|
when: not zreplconf.changed
|
|
service:
|
|
state: started
|
|
enabled: true
|
|
name: zrepl
|
|
|
|
# avoid accidental conflicts of changes on recv (would err 'will not overwrite without force')
|
|
- name: 'zfs: ensure recv mountpoint=off'
|
|
hosts: offsite
|
|
tasks:
|
|
- name: 'zfs: get mountpoint'
|
|
shell: zfs get mountpoint -H -o value {{offsite_dataset}}
|
|
register: result
|
|
changed_when: false
|
|
- when: result.stdout != "none"
|
|
name: 'zfs: ensure mountpoint=off'
|
|
changed_when: true
|
|
shell: zfs set mountpoint=none {{offsite_dataset}}
|
|
register: result
|