homeserver/roles/mgrote.zfs_sanoid/tasks/main.yml
mg 0e80178e9e Rolle: sanoid: systemd-override.d statt direkte Änderungen (#374)
Co-authored-by: Michael Grote <michael.grote@posteo.de>
Reviewed-on: mg/ansible#374
Co-authored-by: mg <michael.grote@posteo.de>
Co-committed-by: mg <michael.grote@posteo.de>
2022-05-27 12:30:43 +02:00

66 lines
1.6 KiB
YAML

---
- name: install packages
become: true
ansible.builtin.apt:
name:
- sanoid
state: present
- name: Create Sanoid Directory
become: true
ansible.builtin.file:
path: "/etc/sanoid"
state: directory
owner: root
group: root
recurse: true
- name: Generate Sanoid Configuration
become: true
ansible.builtin.template:
src: sanoid.conf.j2
dest: "/etc/sanoid/sanoid.conf"
owner: root
group: root
mode: 0644
when: sanoid_datasets is defined and sanoid_templates is defined
- name: template sanoid_mail.service
become: yes
ansible.builtin.template:
src: "sanoid_mail.service.j2"
dest: /etc/systemd/system/sanoid_mail.service
owner: root
group: root
mode: 0644
notify:
- systemctl daemon-reload
- name: add sanoid_mail.service to sanoid.service
become: true
ansible.builtin.blockinfile:
create: yes
mode: 0644
owner: root
group: root
path: /lib/systemd/system/sanoid.service.d/override.conf
block: |
[Unit]
OnFailure = sanoid_mail.service
notify:
- systemctl daemon-reload
- name: set timer
become: true
ansible.builtin.blockinfile:
create: yes
mode: 0644
owner: root
group: root
path: /lib/systemd/system/sanoid.timer.d/override.conf
block: |
[Timer]
OnCalendar = {{ sanoid_timer }}
when: sanoid_timer is defined
notify:
- systemctl daemon-reload