2020-08-18 11:57:53 +02:00
|
|
|
---
|
2021-11-23 21:04:03 +01:00
|
|
|
- name: include user tasks
|
|
|
|
include_tasks: user.yml
|
|
|
|
|
2020-08-18 11:57:53 +02:00
|
|
|
- name: Install Required Packages
|
|
|
|
become: true
|
2021-01-02 10:30:54 +01:00
|
|
|
ansible.builtin.package:
|
2020-08-18 11:57:53 +02:00
|
|
|
name:
|
|
|
|
- ca-certificates
|
|
|
|
- apt-transport-https
|
|
|
|
- software-properties-common
|
|
|
|
- curl
|
|
|
|
- wget
|
|
|
|
- logrotate
|
|
|
|
- libcapture-tiny-perl
|
2021-03-13 12:33:04 +01:00
|
|
|
- libconfig-inifiles-perl
|
2021-07-07 14:11:38 +02:00
|
|
|
- moreutils
|
2020-08-18 11:57:53 +02:00
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create Sanoid Directory
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.file:
|
2020-08-18 11:57:53 +02:00
|
|
|
path: "{{ item }}"
|
|
|
|
state: directory
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
recurse: true
|
|
|
|
with_items:
|
|
|
|
- /usr/local/bin
|
|
|
|
- /etc/sanoid
|
|
|
|
|
|
|
|
- name: Install Sanoid Binary
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.get_url:
|
2021-11-23 21:04:03 +01:00
|
|
|
url: "{{ sanoid_dl_url }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
dest: /usr/local/bin/sanoid
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: Install Sanoid Defaults Configuration
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.get_url:
|
2021-11-23 21:04:03 +01:00
|
|
|
url: "{{ sanoid_dl_conf_url }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
dest: /etc/sanoid/sanoid.defaults.conf
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Generate Sanoid Configuration
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.template:
|
2020-08-18 11:57:53 +02:00
|
|
|
src: sanoid.conf.j2
|
|
|
|
dest: /etc/sanoid/sanoid.conf
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Create Sanoid Log
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.file:
|
2021-11-23 21:04:03 +01:00
|
|
|
path: "{{ sanoid_log_file }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
state: touch
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0644
|
|
|
|
access_time: preserve
|
|
|
|
modification_time: preserve
|
|
|
|
|
2021-03-13 22:11:57 +01:00
|
|
|
- name: copy logrotate config
|
|
|
|
become: yes
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: logrotate_sanoid
|
|
|
|
dest: /etc/logrotate.d/sanoid
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0644
|
|
|
|
|
|
|
|
- name: Generate Sanoid Cron Scripts
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.template:
|
2020-08-18 11:57:53 +02:00
|
|
|
src: sanoid-cron.sh
|
|
|
|
dest: /usr/local/bin/sanoid-cron.sh
|
2021-11-23 21:04:03 +01:00
|
|
|
owner: "{{ sanoid_user }}"
|
|
|
|
group: "{{ sanoid_user_group }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
mode: 0755
|
|
|
|
|
|
|
|
- name: Configure Sanoid Cron Job
|
|
|
|
become: true
|
2020-11-21 19:41:19 +01:00
|
|
|
ansible.builtin.cron:
|
2020-08-18 11:57:53 +02:00
|
|
|
name: sanoid-cron
|
|
|
|
job: /usr/local/bin/sanoid-cron.sh
|
|
|
|
minute: "{{ sanoid_cron_minutes }}"
|
|
|
|
hour: "{{ sanoid_cron_hours }}"
|
2021-11-23 21:04:03 +01:00
|
|
|
user: "{{ sanoid_user }}"
|
2020-08-18 11:57:53 +02:00
|
|
|
state: present
|