feat(base): Add snapper setup stack
Creates separate snapper services for root and home directories. Does _not_ yet set up any btrfs mounts or ensure that they are mounted at the locations.
This commit is contained in:
parent
1691e0402c
commit
e112bb3078
4 changed files with 182 additions and 0 deletions
|
|
@ -131,3 +131,74 @@
|
|||
state: link
|
||||
with_items: [chronyd]
|
||||
listen: installed-chrony
|
||||
|
||||
- name: Set up snapper backups
|
||||
hosts: target_system
|
||||
become: true
|
||||
tags:
|
||||
- btrfs
|
||||
- snapshots
|
||||
tasks:
|
||||
- name: Install snapper
|
||||
community.general.xbps:
|
||||
name:
|
||||
- snapper
|
||||
state: present
|
||||
notify: installed-snapper
|
||||
|
||||
# https://wiki.archlinux.org/title/Snapper#updatedb
|
||||
- name: Disable updatedb indexing for snapshot directories
|
||||
ansible.builtin.copy:
|
||||
content: 'PRUNENAMES = ".snapshots"'
|
||||
dest: "/etc/updatedb.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
force: true
|
||||
|
||||
- name: Ensure snapper configs directory exists
|
||||
ansible.builtin.file:
|
||||
dest: "/etc/snapper/configs"
|
||||
state: directory
|
||||
recurse: true
|
||||
|
||||
- name: Ensure root /.snapshots directory exists
|
||||
ansible.builtin.file:
|
||||
dest: "/.snapshots"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Create root backup configuration
|
||||
ansible.builtin.template:
|
||||
src: snapper-configurations/root.j2
|
||||
dest: "/etc/snapper/configs/root"
|
||||
mode: 0640
|
||||
force: true # ensure contents are always exact
|
||||
|
||||
- name: Ensure home /.snapshots directory exists
|
||||
ansible.builtin.file:
|
||||
dest: "/home/.snapshots"
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Create homedir backup configuration
|
||||
ansible.builtin.template:
|
||||
src: snapper-configurations/home.j2
|
||||
dest: "/etc/snapper/configs/home"
|
||||
mode: 0640
|
||||
force: true
|
||||
|
||||
handlers:
|
||||
# # Do NOT activate the snapperd service -
|
||||
# # on systems without elogind I guess? Unsure
|
||||
# - name: Activate snapper service
|
||||
# ansible.builtin.file:
|
||||
# force: "yes"
|
||||
# src: "/etc/sv/snapperd"
|
||||
# dest: "/etc/runit/runsvdir/default/snapperd"
|
||||
# state: link
|
||||
# listen: installed-snapper
|
||||
- name: Snapper handler stub
|
||||
ansible.builtin.debug:
|
||||
msg: ""
|
||||
listen: installed-snapper
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue