--- - 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: check if lvm.conf does exist stat: path: /etc/lvm/lvm.conf register: zfs_syncoid_lvm_conf - name: configure lvm to ignore zfs volumes when: zfs_syncoid_lvm_conf.stat.exists 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 is defined block: - name: install hdparm package when: zfs_syncoid_autosuspend == 'disks' apt: name: hdparm state: present - name: create systemd override directory for sanoid timer when: zfs_syncoid_autosuspend == 'system' file: path: /etc/systemd/system/sanoid.timer.d state: directory - name: disable persistence of sanoid timer when: zfs_syncoid_autosuspend == 'system' 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