fix(ansible/backup): create /etc/sanoid and install its defaults
Some sanoid packages (e.g. on Ubuntu 26.04) don't ship /etc/sanoid, so the config template failed with 'Destination directory does not exist'. Create the directory explicitly, and copy the packaged sanoid.defaults.conf into it (sanoid requires it beside sanoid.conf) so the first timer run succeeds. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
486a0eaf8e
commit
7a65e7f7c6
3 changed files with 33 additions and 6 deletions
|
|
@ -35,7 +35,7 @@ zfs_child_datasets:
|
||||||
# APT codename for Docker's repo. Defaults to the VM's release. Docker only
|
# APT codename for Docker's repo. Defaults to the VM's release. Docker only
|
||||||
# publishes repos for LTS + recent codenames — on a non-LTS Ubuntu (e.g.
|
# publishes repos for LTS + recent codenames — on a non-LTS Ubuntu (e.g.
|
||||||
# oracular/plucky) set this to the nearest LTS, e.g. "noble".
|
# oracular/plucky) set this to the nearest LTS, e.g. "noble".
|
||||||
docker_apt_codename: "{{ ansible_distribution_release }}"
|
docker_apt_codename: "noble"
|
||||||
# Native ZFS storage driver keeps image layers as ZFS datasets under the pool
|
# Native ZFS storage driver keeps image layers as ZFS datasets under the pool
|
||||||
# (data-root sits on tank/platform/docker). Switch to overlay2 only if you have
|
# (data-root sits on tank/platform/docker). Switch to overlay2 only if you have
|
||||||
# a specific reason.
|
# a specific reason.
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,36 @@
|
||||||
state: present
|
state: present
|
||||||
when: backup_snapshots_enabled
|
when: backup_snapshots_enabled
|
||||||
|
|
||||||
|
- name: Ensure the sanoid config directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/sanoid
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
when: backup_snapshots_enabled
|
||||||
|
|
||||||
|
- name: Locate the packaged sanoid.defaults.conf
|
||||||
|
ansible.builtin.shell: "dpkg -L sanoid | grep -m1 sanoid.defaults.conf"
|
||||||
|
register: sanoid_defaults_src
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
when: backup_snapshots_enabled
|
||||||
|
|
||||||
|
- name: Install sanoid.defaults.conf (sanoid needs it next to sanoid.conf)
|
||||||
|
ansible.builtin.copy:
|
||||||
|
remote_src: true
|
||||||
|
src: "{{ sanoid_defaults_src.stdout }}"
|
||||||
|
dest: /etc/sanoid/sanoid.defaults.conf
|
||||||
|
force: false
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when:
|
||||||
|
- backup_snapshots_enabled
|
||||||
|
- sanoid_defaults_src.stdout | default('') | length > 0
|
||||||
|
- sanoid_defaults_src.stdout != '/etc/sanoid/sanoid.defaults.conf'
|
||||||
|
|
||||||
- name: Configure sanoid snapshot policy
|
- name: Configure sanoid snapshot policy
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: sanoid.conf.j2
|
src: sanoid.conf.j2
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,8 @@
|
||||||
- name: Install Docker Engine + Compose plugin
|
- name: Install Docker Engine + Compose plugin
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- docker-ce
|
- docker.io
|
||||||
- docker-ce-cli
|
- docker-compose-v2
|
||||||
- containerd.io
|
|
||||||
- docker-buildx-plugin
|
|
||||||
- docker-compose-plugin
|
|
||||||
state: present
|
state: present
|
||||||
update_cache: true
|
update_cache: true
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue