ansible-edda/playbooks/tasks/backups/00-zfs-snapshots.d/sanoid.yml

50 lines
1.5 KiB
YAML

- name: Configure sanoid system snapshots
blockinfile:
path: /etc/sanoid/sanoid.conf
create: yes
mode: 0644
insertbefore: "BOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK SYSTEM #"
block: |
[bpool/BOOT]
use_template = system
recursive = yes
process_children_only = yes
[rpool/ROOT]
use_template = system
recursive = yes
process_children_only = yes
[rpool/home]
use_template = system,home
recursive = yes
process_children_only = yes
- name: Configure sanoid service snapshots
blockinfile:
path: /etc/sanoid/sanoid.conf
insertbefore: "# BEGIN ANSIBLE MANAGED BLOCK TEMPLATES #"
marker: "# {mark} ANSIBLE MANAGED BLOCK SERVICE {{ service_name }} #"
block: |
[rpool/var/lib/{{ ansible_hostname }}/data/pod-{{ service_name }}]
use_template = production
recursive = yes
process_children_only = yes
[hpool/backup/{{ ansible_hostname }}/data/pod-{{ service_name }}]
use_template = backup
recursive = yes
process_children_only = yes
with_items: "{{ host_services }}"
loop_control:
loop_var: service_name
- name: Configure sanoid templates
blockinfile:
path: /etc/sanoid/sanoid.conf
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK TEMPLATES #"
block: "{{ lookup('file', './filesystem/{{ ansible_hostname }}/etc/sanoid/sanoid-templates.conf') }}"