summaryrefslogtreecommitdiff
path: root/roles/storage/zfs/syncoid/tasks/main.yml
blob: 53aa434aed8fe73fff76d46bbc8a2d2ab2f41776 (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
---
- 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"