Start of zrepl role.
Currently only doing FreeBSD.
This commit is contained in:
parent
a271d1c756
commit
87c6ad5c5a
@ -1 +1,3 @@
|
|||||||
os_flavor: "freebsd"
|
os_flavor: "freebsd"
|
||||||
|
zfs_snapshot_datasets:
|
||||||
|
- zroot/freebsd/computer/be/default
|
||||||
|
@ -10,3 +10,6 @@ users:
|
|||||||
- name: users
|
- name: users
|
||||||
- name: docker
|
- name: docker
|
||||||
- name: libvirt
|
- name: libvirt
|
||||||
|
zfs_snapshot_datasets:
|
||||||
|
- zroot/linux/archmain/home
|
||||||
|
- zroot/linux/archmain/be
|
||||||
|
@ -4,3 +4,4 @@
|
|||||||
roles:
|
roles:
|
||||||
- sudo
|
- sudo
|
||||||
- users
|
- users
|
||||||
|
- zrepl
|
||||||
|
4
ansible/roles/zrepl/handlers/main.yml
Normal file
4
ansible/roles/zrepl/handlers/main.yml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
- name: restart zrepl
|
||||||
|
service:
|
||||||
|
name: zrepl
|
||||||
|
state: restarted
|
2
ansible/roles/zrepl/meta/main.yaml
Normal file
2
ansible/roles/zrepl/meta/main.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
dependencies:
|
||||||
|
- users
|
31
ansible/roles/zrepl/tasks/common.yaml
Normal file
31
ansible/roles/zrepl/tasks/common.yaml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
- name: Install packages
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- zrepl
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Create directories
|
||||||
|
file:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
mode: 0750
|
||||||
|
owner: root
|
||||||
|
group: wheel
|
||||||
|
loop:
|
||||||
|
- /usr/local/etc/zrepl
|
||||||
|
|
||||||
|
- name: Configure zrepl
|
||||||
|
template:
|
||||||
|
src: templates/zrepl.yml.j2
|
||||||
|
dest: /usr/local/etc/zrepl/zrepl.yml
|
||||||
|
mode: 0440
|
||||||
|
owner: root
|
||||||
|
group: wheel
|
||||||
|
validate: "zrepl configcheck --config %s"
|
||||||
|
notify: "restart zrepl"
|
||||||
|
|
||||||
|
- include: tasks/freebsd.yaml
|
||||||
|
when: 'os_flavor == "freebsd"'
|
||||||
|
|
||||||
|
- include: tasks/linux.yaml
|
||||||
|
when: 'os_flavor == "linux"'
|
0
ansible/roles/zrepl/tasks/freebsd.yaml
Normal file
0
ansible/roles/zrepl/tasks/freebsd.yaml
Normal file
0
ansible/roles/zrepl/tasks/linux.yaml
Normal file
0
ansible/roles/zrepl/tasks/linux.yaml
Normal file
2
ansible/roles/zrepl/tasks/main.yaml
Normal file
2
ansible/roles/zrepl/tasks/main.yaml
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
- include: tasks/common.yaml
|
||||||
|
when: zfs_snapshot_datasets is defined
|
29
ansible/roles/zrepl/templates/zrepl.yml.j2
Normal file
29
ansible/roles/zrepl/templates/zrepl.yml.j2
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
jobs:
|
||||||
|
|
||||||
|
# this job takes care of snapshot creation + pruning
|
||||||
|
- name: snapjob
|
||||||
|
type: snap
|
||||||
|
filesystems: {
|
||||||
|
{% for dataset in zfs_snapshot_datasets %}
|
||||||
|
"{{dataset}}<": true,
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
# create snapshots with prefix `zrepl_` every 15 minutes
|
||||||
|
snapshotting:
|
||||||
|
type: periodic
|
||||||
|
interval: 15m
|
||||||
|
prefix: zrepl_
|
||||||
|
pruning:
|
||||||
|
keep:
|
||||||
|
# fade-out scheme for snapshots starting with `zrepl_`
|
||||||
|
# - keep all created in the last hour
|
||||||
|
# - then destroy snapshots such that we keep 24 each 1 hour apart
|
||||||
|
# - then destroy snapshots such that we keep 14 each 1 day apart
|
||||||
|
# - then destroy all older snapshots
|
||||||
|
- type: grid
|
||||||
|
grid: 1x1h(keep=all) | 24x1h | 14x1d
|
||||||
|
regex: "^zrepl_.*"
|
||||||
|
# keep all snapshots that don't have the `zrepl_` prefix
|
||||||
|
- type: regex
|
||||||
|
negate: true
|
||||||
|
regex: "^zrepl_.*"
|
Loading…
x
Reference in New Issue
Block a user