ansible-edda/playbooks/roles/backups/snapshots/setup/tasks/main.yml

65 lines
1.9 KiB
YAML

---
- name: "install sanoid and syncoid"
ansible.builtin.apt:
name:
- "sanoid"
- "python3-yaml"
- name: "create sanoid configuration directory"
ansible.builtin.file:
path: "/etc/sanoid"
state: "directory"
mode: 0755
- name: "configure sanoid templates"
ansible.builtin.blockinfile:
path: "/etc/sanoid/sanoid.conf"
create: true
mode: 0644
insertafter: "EOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK TEMPLATES #"
block: "{{ lookup('file', './sanoid-templates.conf') }}"
- name: "configure sanoid system snapshots"
ansible.builtin.blockinfile:
path: "/etc/sanoid/sanoid.conf"
insertbefore: "BOF"
marker: "# {mark} ANSIBLE MANAGED BLOCK SYSTEM {{ item.name }} #"
# Note that the {{ '' }} is required to force a newline.
block: |
[{{ item.name }}]
use_template = {{ item.templates | join(',') }}
recursive = {% if item.recursive %}yes{% else %}no{% endif %}{{ '' }}
process_children_only = {% if item.children_only %}yes{% else %}no{% endif %}{{ '' }}
loop: "{{ backups_snapshots_sanoid_system_datasets | reverse }}"
- name: "create syncoid-batch config directory"
ansible.builtin.file:
path: "{{ system_etc_root_directory }}/syncoid-batch.d"
state: "directory"
mode: 0755
- name: "install syncoid-batch script"
ansible.builtin.copy:
src: "./syncoid-batch"
dest: "/usr/local/sbin/syncoid-batch"
mode: 0755
- name: "install syncoid-batch service"
ansible.builtin.template:
src: "./syncoid-batch.service"
dest: "/etc/systemd/system/syncoid-batch.service"
mode: 0644
register: services_backups_snapshots_syncoid_volume_data_service_file
- name: "systemd daemon reload"
ansible.builtin.systemd:
daemon_reload: true
when:
services_backups_snapshots_syncoid_volume_data_service_file.changed
- name: "enable syncoid-batch service"
ansible.builtin.systemd:
name: "syncoid-batch.service"
enabled: true