2021-11-30 13:44:54 +01:00
|
|
|
---
|
2022-04-01 18:06:15 +02:00
|
|
|
- name: install packages
|
2021-11-30 13:44:54 +01:00
|
|
|
become: true
|
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
2022-04-01 18:06:15 +02:00
|
|
|
- sanoid
|
2021-11-30 13:44:54 +01:00
|
|
|
state: present
|
2022-04-02 15:15:43 +02:00
|
|
|
register: install
|
|
|
|
|
|
|
|
- name: systemctl daemon-reload
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
daemon_reload: yes
|
|
|
|
when: install.changed
|
2021-11-30 13:44:54 +01:00
|
|
|
|
2022-04-01 19:00:06 +02:00
|
|
|
- name: Create Sanoid Directory
|
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
2022-04-01 19:08:49 +02:00
|
|
|
path: "/etc/sanoid"
|
2022-04-01 19:00:06 +02:00
|
|
|
state: directory
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
recurse: true
|
2022-04-01 19:08:49 +02:00
|
|
|
|
2021-11-30 13:44:54 +01:00
|
|
|
- name: Generate Sanoid Configuration
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: sanoid.conf.j2
|
2022-04-01 19:08:49 +02:00
|
|
|
dest: "/etc/sanoid/sanoid.conf"
|
2022-04-01 18:12:09 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
2021-11-30 13:44:54 +01:00
|
|
|
mode: 0644
|
2022-04-01 18:54:00 +02:00
|
|
|
when: sanoid_datasets is defined and sanoid_templates is defined
|
2022-04-01 18:23:01 +02:00
|
|
|
|
2022-04-01 18:24:34 +02:00
|
|
|
- name: template sanoid_mail.service
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
2022-04-01 19:08:49 +02:00
|
|
|
src: "sanoid_mail.service.j2"
|
2022-04-01 18:24:34 +02:00
|
|
|
dest: /etc/systemd/system/sanoid_mail.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2022-04-01 18:23:01 +02:00
|
|
|
|
2022-04-01 18:24:34 +02:00
|
|
|
- name: add sanoid_mail.service to sanoid.service
|
2022-04-01 18:23:01 +02:00
|
|
|
become: true
|
|
|
|
community.general.ini_file:
|
2022-04-01 18:47:40 +02:00
|
|
|
path: "/etc/systemd/system/sanoid.service"
|
2022-04-01 18:23:01 +02:00
|
|
|
section: Unit
|
|
|
|
state: present
|
|
|
|
no_extra_spaces: no
|
|
|
|
option: OnFailure
|
|
|
|
value: sanoid_mail.service
|
2022-04-01 18:34:15 +02:00
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2022-04-01 18:27:07 +02:00
|
|
|
|
2022-04-01 18:47:40 +02:00
|
|
|
- name: set timer
|
2022-04-01 18:39:23 +02:00
|
|
|
become: true
|
|
|
|
community.general.ini_file:
|
2022-04-01 18:47:40 +02:00
|
|
|
path: "/etc/systemd/system/sanoid.timer"
|
2022-04-01 18:39:23 +02:00
|
|
|
section: Timer
|
|
|
|
state: present
|
|
|
|
no_extra_spaces: no
|
|
|
|
option: OnCalendar
|
|
|
|
value: "{{ sanoid_timer }}"
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
2022-04-01 18:54:00 +02:00
|
|
|
when: sanoid_timer is defined
|