2021-11-30 13:44:54 +01:00
|
|
|
---
|
|
|
|
- name: include user tasks
|
|
|
|
include_tasks: user.yml
|
|
|
|
|
|
|
|
- name: Install Required Packages
|
|
|
|
become: true
|
|
|
|
ansible.builtin.package:
|
|
|
|
name:
|
|
|
|
- ca-certificates
|
|
|
|
- apt-transport-https
|
|
|
|
- software-properties-common
|
|
|
|
- curl
|
|
|
|
- wget
|
|
|
|
- logrotate
|
|
|
|
- libcapture-tiny-perl
|
|
|
|
- libconfig-inifiles-perl
|
|
|
|
- moreutils
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create Sanoid Directory
|
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
|
|
|
recurse: true
|
|
|
|
with_items:
|
|
|
|
- /etc/sanoid
|
|
|
|
|
|
|
|
- name: Install Sanoid Binary
|
|
|
|
become: true
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ sanoid_dl_url }}"
|
|
|
|
dest: /usr/local/bin/sanoid
|
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: Install Sanoid Defaults Configuration
|
|
|
|
become: true
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ sanoid_dl_conf_url }}"
|
|
|
|
dest: /etc/sanoid/sanoid.defaults.conf
|
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Generate Sanoid Configuration
|
|
|
|
become: true
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: sanoid.conf.j2
|
|
|
|
dest: /etc/sanoid/sanoid.conf
|
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
|
|
|
mode: 0644
|
|
|
|
|
2022-04-01 17:58:31 +02:00
|
|
|
- name: template sanoid.service
|
2022-04-01 17:56:50 +02:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
2022-04-01 17:58:31 +02:00
|
|
|
src: sanoid.service.j2
|
|
|
|
dest: /etc/systemd/system/sanoid.service
|
2022-04-01 17:56:50 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
|
2022-04-01 17:58:31 +02:00
|
|
|
- name: template sanoid_mail.service
|
2022-04-01 17:56:50 +02:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
2022-04-01 17:58:31 +02:00
|
|
|
src: sanoid_mail.service.j2
|
|
|
|
dest: /etc/systemd/system/sanoid_mail.service
|
2022-04-01 17:56:50 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
|
|
|
|
|
2022-04-01 17:58:31 +02:00
|
|
|
- name: template sanoid.timer
|
2022-04-01 17:56:50 +02:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
2022-04-01 17:58:31 +02:00
|
|
|
src: sanoid.timer.j2
|
|
|
|
dest: /etc/systemd/system/sanoid.timer
|
2022-04-01 17:56:50 +02:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
notify:
|
|
|
|
- systemctl daemon-reload
|
|
|
|
|
2022-04-01 17:58:31 +02:00
|
|
|
- name: systemctl start sanoid.timer
|
2022-04-01 17:56:50 +02:00
|
|
|
become: yes
|
|
|
|
ansible.builtin.systemd:
|
2022-04-01 17:58:31 +02:00
|
|
|
name: sanoid.timer
|
2022-04-01 17:56:50 +02:00
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# remove old!!!
|
|
|
|
|
2021-11-30 13:44:54 +01:00
|
|
|
- name: Create Sanoid Log
|
|
|
|
become: true
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ sanoid_log_file }}"
|
2022-04-01 17:56:50 +02:00
|
|
|
state: absent
|
2021-11-30 13:44:54 +01:00
|
|
|
|
|
|
|
- name: copy logrotate config
|
|
|
|
become: yes
|
2022-04-01 17:56:50 +02:00
|
|
|
ansible.builtin.file:
|
|
|
|
state: absent
|
|
|
|
path: /etc/logrotate.d/sanoid
|
2021-11-30 13:44:54 +01:00
|
|
|
|
|
|
|
- name: Generate Sanoid Cron Scripts
|
|
|
|
become: true
|
2022-04-01 17:56:50 +02:00
|
|
|
ansible.builtin.file:
|
|
|
|
state: absent
|
|
|
|
path: /usr/local/bin/sanoid-cron.sh
|
2021-11-30 13:44:54 +01:00
|
|
|
|
|
|
|
- name: Configure Sanoid Cron Job
|
|
|
|
become: true
|
|
|
|
ansible.builtin.cron:
|
|
|
|
name: sanoid-cron
|
|
|
|
job: /usr/local/bin/sanoid-cron.sh
|
|
|
|
minute: "{{ sanoid_cron_minutes }}"
|
|
|
|
hour: "{{ sanoid_cron_hours }}"
|
|
|
|
user: "{{ sanoid_user }}"
|
2022-04-01 17:56:50 +02:00
|
|
|
state: absent
|