blob: a01900b1e1dbcbd7bc177511c2c681bad668403e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
---
- name: install sanoid package
apt:
name: sanoid
state: present
- name: create syncoid directory
file:
path: /var/lib/syncoid
state: directory
mode: 0700
- name: genarate ssh keypair for syncoid
openssh_keypair:
path: /var/lib/syncoid/id_ssh_ed25519
type: ed25519
comment: ZFS Backup syncoid@{{ host_name }}
- name: generate syncoid ssh config wrapper
copy:
content: |
#!/bin/bash
exec /usr/sbin/syncoid --sshoption "UserKnownHostsFile=/var/lib/syncoid/ssh.knownhosts" --sshoption "HashKnownHosts=no" --sshkey "/var/lib/syncoid/id_ssh_ed25519" --no-sync-snap --compress zstd-fast "$@"
dest: /var/lib/syncoid/syncoid_wrapper
mode: 0755
- name: configure lvm to ignore zfs volumes
lineinfile:
path: /etc/lvm/lvm.conf
backrefs: yes
regexp: '^\s*#?\s*global_filter\s*='
line: ' global_filter = [ "r|/dev/zd[0-9]+|" ]'
- name: create target datasets
loop: "{{ zfs_syncoid_sources | dict2items }}"
loop_control:
loop_var: source
label: "{{ source.key }}"
include_tasks: datasets.yml
- name: create systemd units
loop: "{{ zfs_syncoid_sources | dict2items }}"
loop_control:
label: "{{ item.key }}"
template:
src: systemd.service.j2
dest: "/etc/systemd/system/syncoid-{{ item.key }}.service"
- name: create systemd timer units for periodic backups
loop: "{{ zfs_syncoid_sources | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: "'periodic' in item.value"
template:
src: systemd.timer.j2
dest: "/etc/systemd/system/syncoid-{{ item.key }}.timer"
- name: make sure systemd timer units for periodic backups are enabled and started
loop: "{{ zfs_syncoid_sources | dict2items }}"
loop_control:
label: "{{ item.key }}"
when: "'periodic' in item.value"
systemd:
daemon_reload: yes
name: "syncoid-{{ item.key }}.timer"
state: started
enabled: yes
|