15d783de86
* template --> ansible.builtin.template * apt --> ansible.builtin.apt * lineinfile --> ansible.builtin.lineinfile * file --> ansible.builtin.file * blockinfile --> ansible.builtin.blockinfile * cron --> ansible.builtin.cron * timezone --> ansible.builtin.timezone * get_url --> ansible.builtin.get_url * group --> ansible.builtin.group * user --> ansible.builtin.user * unarchive --> ansible.builtin.unarchive * service --> ansible.builtin.service * apache2_module --> ansible.builtin.apache2_module * package --> ansible.builtin.apt * template --> ansible.builtin.template 2
116 lines
2.7 KiB
YAML
116 lines
2.7 KiB
YAML
---
|
|
- name: Install Required Packages
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name:
|
|
- ca-certificates
|
|
- apt-transport-https
|
|
- software-properties-common
|
|
- curl
|
|
- wget
|
|
- rsync
|
|
- logrotate
|
|
- libcapture-tiny-perl
|
|
state: present
|
|
|
|
- name: Create Sanoid Directory
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
recurse: true
|
|
with_items:
|
|
- /usr/local/bin
|
|
- /etc/sanoid
|
|
|
|
- name: Install Sanoid Dependencies Packages
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name:
|
|
- libconfig-inifiles-perl
|
|
force_apt_get: yes
|
|
update_cache: yes
|
|
autoremove: yes
|
|
autoclean: yes
|
|
state: present
|
|
|
|
- name: Install Sanoid Binary
|
|
become: true
|
|
ansible.builtin.get_url:
|
|
url: https://raw.githubusercontent.com/jimsalterjrs/sanoid/master/sanoid
|
|
dest: /usr/local/bin/sanoid
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- name: Install Sanoid Defaults Configuration
|
|
become: true
|
|
ansible.builtin.get_url:
|
|
url: https://raw.githubusercontent.com/jimsalterjrs/sanoid/master/sanoid.defaults.conf
|
|
dest: /etc/sanoid/sanoid.defaults.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
|
|
- name: Generate Sanoid Configuration
|
|
become: true
|
|
ansible.builtin.template:
|
|
src: sanoid.conf.j2
|
|
dest: /etc/sanoid/sanoid.conf
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
|
|
- name: Create Sanoid Log
|
|
become: true
|
|
ansible.builtin.file:
|
|
path: /var/log/sanoid-cron.log
|
|
state: touch
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
access_time: preserve
|
|
modification_time: preserve
|
|
|
|
- name: Add Sanoid Log to be Rotated
|
|
become: true
|
|
ansible.builtin.blockinfile:
|
|
path: /etc/logrotate.d/sanoid
|
|
state: present
|
|
create: yes
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
block: |
|
|
/var/log/sanoid-cron.log {
|
|
su root root
|
|
create 0640 root root
|
|
rotate 4
|
|
weekly
|
|
compress
|
|
missingok
|
|
notifempty
|
|
dateext
|
|
dateyesterday
|
|
}
|
|
|
|
- name: Generate Sanoid Cron Scripts
|
|
become: true
|
|
ansible.builtin.template:
|
|
src: sanoid-cron.sh
|
|
dest: /usr/local/bin/sanoid-cron.sh
|
|
owner: root
|
|
group: root
|
|
mode: 0755
|
|
|
|
- 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: root
|
|
state: present
|