2021-11-30 13:44:54 +01:00
|
|
|
---
|
2022-04-03 11:04:27 +02:00
|
|
|
- name: install packages
|
2021-11-30 13:44:54 +01:00
|
|
|
become: true
|
2022-04-03 11:04:27 +02:00
|
|
|
ansible.builtin.apt:
|
2021-11-30 13:44:54 +01:00
|
|
|
name:
|
2022-04-03 11:04:27 +02:00
|
|
|
- sanoid
|
2021-11-30 13:44:54 +01:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create Sanoid Directory
|
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
2022-04-03 11:04:27 +02:00
|
|
|
path: "/etc/sanoid"
|
2021-11-30 13:44:54 +01:00
|
|
|
state: directory
|
2022-04-03 11:04:27 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2021-11-30 13:44:54 +01:00
|
|
|
recurse: true
|
|
|
|
|
|
|
|
- name: Generate Sanoid Configuration
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: sanoid.conf.j2
|
2022-04-03 11:04:27 +02:00
|
|
|
dest: "/etc/sanoid/sanoid.conf"
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-11-30 13:44:54 +01:00
|
|
|
mode: 0644
|
2022-04-03 11:04:27 +02:00
|
|
|
when: sanoid_datasets is defined and sanoid_templates is defined
|
2021-11-30 13:44:54 +01:00
|
|
|
|
2022-04-03 11:04:27 +02:00
|
|
|
- name: template sanoid_mail.service
|
2021-11-30 13:44:54 +01:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
2022-04-03 11:04:27 +02:00
|
|
|
src: "sanoid_mail.service.j2"
|
|
|
|
dest: /etc/systemd/system/sanoid_mail.service
|
2022-01-24 07:53:01 +01:00
|
|
|
owner: root
|
2022-04-03 11:04:27 +02:00
|
|
|
group: root
|
2021-11-30 13:44:54 +01:00
|
|
|
mode: 0644
|
2022-04-03 11:04:27 +02:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2021-11-30 13:44:54 +01:00
|
|
|
|
2022-04-03 11:04:27 +02:00
|
|
|
- name: add sanoid_mail.service to sanoid.service
|
2021-11-30 13:44:54 +01:00
|
|
|
become: true
|
2022-05-27 12:30:43 +02:00
|
|
|
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
|
2022-04-03 11:04:27 +02:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2021-11-30 13:44:54 +01:00
|
|
|
|
2022-04-03 11:04:27 +02:00
|
|
|
- name: set timer
|
2021-11-30 13:44:54 +01:00
|
|
|
become: true
|
2022-05-27 12:30:43 +02:00
|
|
|
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
|
2022-04-03 11:04:27 +02:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|