blob: 9e573db7d39885bc36130a21b61343697ff262d9 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
---
- 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 pull script
template:
src: syncoid_pull.j2
dest: /var/lib/syncoid/syncoid_pull
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: pull.service.j2
dest: "/etc/systemd/system/syncoid-pull-{{ 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: pull.timer.j2
dest: "/etc/systemd/system/syncoid-pull-{{ 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-pull-{{ item.key }}.timer"
state: started
enabled: yes
- name: enable autosuspend
when: zfs_syncoid_autosuspend
block:
- name: create systemd override directory for sanoid timer
file:
path: /etc/systemd/system/sanoid.timer.d
state: directory
- name: disable persistence of sanoid timer
copy:
content: |
[Timer]
Persistent=false
dest: /etc/systemd/system/sanoid.timer.d/no-persistence.conf
- name: install python deps
apt:
name: "{{ python_basename }}-dbus"
state: present
- name: install autosuspend script
template:
src: autosuspend.py.j2
dest: /usr/local/bin/syncoid-autosuspend.py
mode: 0755
- name: install autosuspend systemd units
loop:
- service
- timer
template:
src: "autosuspend.{{ item }}.j2"
dest: "/etc/systemd/system/syncoid-autosuspend.{{ item }}"
- name: make sure autosuspend timer unit is enabled and started
systemd:
daemon_reload: yes
name: syncoid-autosuspend.timer
enabled: yes
state: started
- name: generate syncoid finalize script
template:
src: syncoid_finalize.j2
dest: /var/lib/syncoid/syncoid_finalize
mode: 0755
|