wip
This commit is contained in:
parent
063555a55d
commit
1d9ddbae8a
10 changed files with 5 additions and 241 deletions
|
@ -1,15 +1,4 @@
|
|||
---
|
||||
### under which user the script is run
|
||||
sanoid_user_group: "root"
|
||||
sanoid_user: "sanoid"
|
||||
|
||||
### where to store the logfile
|
||||
sanoid_log_file: "/var/log/sanoid-cron.log"
|
||||
|
||||
### where to download the binary + config
|
||||
sanoid_dl_url: "https://raw.githubusercontent.com/jimsalterjrs/sanoid/master/sanoid"
|
||||
sanoid_dl_conf_url: "https://raw.githubusercontent.com/jimsalterjrs/sanoid/master/sanoid.defaults.conf"
|
||||
|
||||
### when should the script be run
|
||||
sanoid_cron_hours: '*'
|
||||
sanoid_cron_minutes: '*'
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
---
|
||||
- name: systemctl daemon-reload
|
||||
become: yes
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: yes
|
||||
|
||||
- name: systemctl enable units
|
||||
become: yes
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
enabled: yes
|
||||
masked: no
|
||||
with_items:
|
||||
- sanoid.service
|
||||
- sanoid_mail.service
|
||||
- sanoid.timer
|
||||
|
||||
- name: systemctl start units
|
||||
become: yes
|
||||
ansible.builtin.systemd:
|
||||
name: "{{ item }}"
|
||||
state: restarted
|
||||
enabled: yes
|
||||
with_items:
|
||||
- sanoid.timer
|
||||
notify: systemctl daemon-reload
|
|
@ -1,56 +1,14 @@
|
|||
---
|
||||
- name: include user tasks
|
||||
- name: include user tasks # entfernen
|
||||
include_tasks: user.yml
|
||||
|
||||
- name: Install Required Packages
|
||||
- name: install 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
|
||||
- debhelper
|
||||
- pv
|
||||
- lzop
|
||||
- mbuffer
|
||||
- build-essential
|
||||
- sanoid
|
||||
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:
|
||||
|
@ -59,77 +17,3 @@
|
|||
owner: "{{ sanoid_user }}"
|
||||
group: "{{ sanoid_user_group }}"
|
||||
mode: 0644
|
||||
|
||||
- name: template sanoid.service
|
||||
become: yes
|
||||
ansible.builtin.template:
|
||||
src: sanoid.service.j2
|
||||
dest: /etc/systemd/system/sanoid.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- systemctl daemon-reload
|
||||
|
||||
- name: template sanoid_mail.service
|
||||
become: yes
|
||||
ansible.builtin.template:
|
||||
src: sanoid_mail.service.j2
|
||||
dest: /etc/systemd/system/sanoid_mail.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- systemctl daemon-reload
|
||||
|
||||
|
||||
- name: template sanoid.timer
|
||||
become: yes
|
||||
ansible.builtin.template:
|
||||
src: sanoid.timer.j2
|
||||
dest: /etc/systemd/system/sanoid.timer
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
notify:
|
||||
- systemctl daemon-reload
|
||||
|
||||
- name: systemctl start sanoid.timer
|
||||
become: yes
|
||||
ansible.builtin.systemd:
|
||||
name: sanoid.timer
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
|
||||
|
||||
|
||||
# remove old!!!
|
||||
|
||||
- name: Create Sanoid Log
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: "{{ sanoid_log_file }}"
|
||||
state: absent
|
||||
|
||||
- name: copy logrotate config
|
||||
become: yes
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: /etc/logrotate.d/sanoid
|
||||
|
||||
- name: Generate Sanoid Cron Scripts
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
state: absent
|
||||
path: /usr/local/bin/sanoid-cron.sh
|
||||
|
||||
- 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 }}"
|
||||
state: absent
|
||||
|
|
|
@ -1,22 +1,13 @@
|
|||
---
|
||||
- name: ensure group exists
|
||||
become: true
|
||||
ansible.builtin.group:
|
||||
name: "{{ sanoid_user_group }}"
|
||||
state: present
|
||||
when:
|
||||
- sanoid_user_group is defined
|
||||
|
||||
- name: ensure user exists
|
||||
- name: ensure user exists # ENTRFERNERN!!!!!
|
||||
become: true
|
||||
ansible.builtin.user:
|
||||
name: "{{ sanoid_user }}"
|
||||
group: "{{ sanoid_user_group }}"
|
||||
shell: /usr/sbin/nologin
|
||||
create_home: no
|
||||
when:
|
||||
- sanoid_user_group is defined
|
||||
- sanoid_user is defined
|
||||
state: absent
|
||||
|
||||
- name: add user to sudoers # ENTRFERNERN!!!!!
|
||||
become: true
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
{{ file_header | default () }}
|
||||
{{ sanoid_log_file }} {
|
||||
su root root
|
||||
create 0644 root root
|
||||
rotate 4
|
||||
weekly
|
||||
compress
|
||||
missingok
|
||||
notifempty
|
||||
dateext
|
||||
dateyesterday
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
#!/bin/bash
|
||||
{{ file_header | default () }}
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
sudo /usr/local/bin/sanoid --cron --verbose | ts '%Y-%m-%d - %H-%M-%S' >> {{ sanoid_log_file }} 2>&1 &
|
|
@ -1,29 +0,0 @@
|
|||
{{ file_header | default () }}
|
||||
## ZFS Section -------------------------------- ##
|
||||
{% for item in sanoid_datasets if item.snapshots is sameas true %}
|
||||
{% if item.snapshots is sameas true %}
|
||||
[{{ item.path }}]
|
||||
use_template = {{ item.template }}
|
||||
recursive = {{ item.recursive }}
|
||||
## -------------------------------------------- ##
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
## Template Section --------------------------- ##
|
||||
{% for item in sanoid_templates %}
|
||||
[template_{{ item.name }}]
|
||||
## Keep-Rules
|
||||
hourly = {{ item.keep_hourly }}
|
||||
daily = {{ item.keep_daily }}
|
||||
monthly = {{ item.keep_monthly }}
|
||||
yearly = {{ item.keep_yearly }}
|
||||
frequently = {{ item.frequently }}
|
||||
## Interval
|
||||
frequent_period = {{ item.frequent_period }}
|
||||
## Other Options
|
||||
autosnap = {{ item.autosnap }}
|
||||
autoprune = {{ item.autoprune }}
|
||||
## -------------------------------------------- ##
|
||||
{% endfor %}
|
|
@ -1,9 +0,0 @@
|
|||
{{ file_header | default () }}
|
||||
[Unit]
|
||||
Description=Trigger zfs-snapshots with sanoid.
|
||||
After=multi-user.target
|
||||
OnFailure=cv4pve_mail.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/cv4pve/cv4pve-autosnap --host=127.0.0.1 --api-token {{ cv4pve_api_user }}={{ cv4pve_api_token }} --vmid="{{ cv4pve_vmid }}" snap --label='daily' --keep="{{ cv4pve_keep_snapshots }}" --state
|
|
@ -1,11 +0,0 @@
|
|||
{{ file_header | default () }}
|
||||
[Unit]
|
||||
Description=Timer: Trigger VM-Snapshots in PVE with cv4pve.
|
||||
|
||||
[Timer]
|
||||
OnCalendar=*-*-* {{ cv4pve_cron_hour }}:{{ cv4pve_cron_minute }}:00
|
||||
RandomizedDelaySec=10 min
|
||||
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target multi-user.target
|
|
@ -1,8 +0,0 @@
|
|||
{{ file_header | default () }}
|
||||
|
||||
[Unit]
|
||||
Description=Send a Mail in case of an error in cv4pve.service.
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/bin/bash -c '/bin/systemctl status cv4pve.service | mail -s "[ERROR] cv4pve - %H" {{ empfaenger_mail }}'
|
Loading…
Reference in a new issue