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

70 lines
2.0 KiB
YAML
Raw Normal View History

2022-12-18 00:44:32 +01:00
- 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: "/etc/syncoid-batch.d"
state: "directory"
mode: 0755
2022-12-18 17:06:27 +01:00
- name: "install syncoid-batch script"
2022-12-18 00:44:32 +01:00
ansible.builtin.copy:
src: "./syncoid-batch"
dest: "/usr/local/sbin/syncoid-batch"
mode: 0755
- name: "install syncoid-batch service"
ansible.builtin.copy:
src: "./syncoid-batch.service"
dest: "/etc/systemd/system/syncoid-batch.service"
mode: 0644
register: services_backups_snapshots_syncoid_volume_data_service_file
2022-12-18 17:06:27 +01:00
- name: "systemd daemon reload"
2022-12-18 00:44:32 +01:00
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
- name: "enable sanoid service"
ansible.builtin.systemd:
name: "sanoid.timer"
enabled: true
state: "started"