Sanoid Templates als Variablen (#19)

Aufräumen

In GroupVars eingebaut

Templates als Vars

Doku aktualisiert

Typo

neues Dictionary-Format

Vars: zfs_pool --> zfs_pools

Co-authored-by: Michael Grote <38253905+quotengrote@users.noreply.github.com>
Reviewed-on: mg/ansible#19
Co-Authored-By: mg <michael.grote@posteo.de>
Co-Committed-By: mg <michael.grote@posteo.de>
This commit is contained in:
Michael Grote 2020-12-31 01:36:22 +01:00
parent e1cc8f6d35
commit 1fc7975323
7 changed files with 190 additions and 84 deletions

View file

@ -1,24 +1,68 @@
--- ---
### mgrote.smb_fileserver ### mgrote.smb_fileserver
smb_nutzer: smb_nutzer:
- { name: 'annemariedroessler', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_amd', 'password') }}" } - name: 'annemariedroessler'
- { name: 'restic', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_restic', 'password') }}" } groups: 'users'
- { name: 'win10', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_win10', 'password') }}" } password: "{{ lookup('keepass', 'fileserver_smb_user_amd', 'password') }}"
- { name: 'kodi', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_kodi', 'password') }}" } - name: 'restic'
- { name: 'michaelgrote', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_mg', 'password') }}" } groups: 'users'
- { name: 'navidrome', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_navidrome', 'password') }}" } password: "{{ lookup('keepass', 'fileserver_smb_user_restic', 'password') }}"
- { name: 'docker', groups: 'users', password: "{{ lookup('keepass', 'fileserver_smb_user_docker', 'password') }}" } - name: 'win10'
groups: 'users'
password: "{{ lookup('keepass', 'fileserver_smb_user_win10', 'password') }}"
- name: 'kodi'
groups: 'users'
password: "{{ lookup('keepass', 'fileserver_smb_user_kodi', 'password') }}"
- name: 'michaelgrote'
groups: 'users'
password: "{{ lookup('keepass', 'fileserver_smb_user_mg', 'password') }}"
- name: 'navidrome'
groups: 'users'
password: "{{ lookup('keepass', 'fileserver_smb_user_navidrome', 'password') }}"
- name: 'docker'
groups: 'users'
password: "{{ lookup('keepass', 'fileserver_smb_user_docker', 'password') }}"
smb_freigaben: smb_freigaben:
- { freigabename: 'videos', ordnerpfad: '/shares_videos', lese_nutzer: ' kodi', schreibe_nutzer: 'annemariedroessler michaelgrote' } - freigabename: 'videos'
- { freigabename: 'ag', ordnerpfad: '/shares/ag', lese_nutzer: '', schreibe_nutzer: ' michaelgrote' } ordnerpfad: '/shares_videos'
- { freigabename: 'amd', ordnerpfad: '/shares/amd', lese_nutzer: 'navidrome michaelgrote', schreibe_nutzer: 'annemariedroessler' } lese_nutzer: ' kodi'
- { freigabename: 'backup', ordnerpfad: '/shares/Backup', lese_nutzer: '', schreibe_nutzer: 'annemariedroessler restic win10 michaelgrote' } schreibe_nutzer: 'annemariedroessler michaelgrote'
- { freigabename: 'hm', ordnerpfad: '/shares/hm', lese_nutzer: '', schreibe_nutzer: 'michaelgrote' } - freigabename: 'ag'
- { freigabename: 'mg', ordnerpfad: '/shares/mg', lese_nutzer: '', schreibe_nutzer: 'win10 michaelgrote' } ordnerpfad: '/shares/ag'
- { freigabename: 'musik', ordnerpfad: '/shares/Musik', lese_nutzer: 'navidrome kodi annemariedroessler ', schreibe_nutzer: 'win10 michaelgrote' } lese_nutzer: ''
- { freigabename: 'tmp', ordnerpfad: '/shares/tmp', lese_nutzer: '', schreibe_nutzer: 'kodi annemariedroessler restic win10 michaelgrote' } schreibe_nutzer: 'michaelgrote'
- { freigabename: 'bilder', ordnerpfad: '/shares/bilder', lese_nutzer: '', schreibe_nutzer: 'annemariedroessler michaelgrote' } - freigabename: 'amd'
- { freigabename: 'docker', ordnerpfad: '/shares/docker', lese_nutzer: '', schreibe_nutzer: 'docker' } ordnerpfad: '/shares/amd'
lese_nutzer: 'navidrome michaelgrote'
schreibe_nutzer: 'annemariedroessler'
- freigabename: 'backup'
ordnerpfad: '/shares/Backup'
lese_nutzer: ''
schreibe_nutzer: 'annemariedroessler restic win10 michaelgrote'
- freigabename: 'hm'
ordnerpfad: '/shares/hm'
lese_nutzer: ''
schreibe_nutzer: 'michaelgrote'
- freigabename: 'mg'
ordnerpfad: '/shares/mg'
lese_nutzer: ''
schreibe_nutzer: 'win10 michaelgrote'
- freigabename: 'musik'
ordnerpfad: '/shares/Musik'
lese_nutzer: 'navidrome kodi annemariedroessler '
schreibe_nutzer: 'win10 michaelgrote'
- freigabename: 'tmp'
ordnerpfad: '/shares/tmp'
lese_nutzer: ''
schreibe_nutzer: 'kodi annemariedroessler restic win10 michaelgrote'
- freigabename: 'bilder'
ordnerpfad: '/shares/bilder'
lese_nutzer: ''
schreibe_nutzer: 'annemariedroessler michaelgrote'
- freigabename: 'docker'
ordnerpfad: '/shares/docker'
lese_nutzer: ''
schreibe_nutzer: 'docker'
smb_workgroup: WORKGROUP smb_workgroup: WORKGROUP
smb_nutzer_loeschen: smb_nutzer_loeschen:

View file

@ -12,8 +12,31 @@
- .gitconfig - .gitconfig
### mgrote.sanoid ### mgrote.sanoid
sanoid_datasets: sanoid_datasets:
- { path: 'hdd_data_raidz/data', template: 'fiveminutes', recursive: ' no' } - path: 'hdd_data_raidz/data'
- { path: 'hdd_data_raidz/videos', template: 'hourly', recursive: ' yes' } template: 'fiveminutes' # muss in Templates angelegt sein
recursive: ' no'
- path: 'hdd_data_raidz/videos'
template: 'hourly'
recursive: ' yes'
sanoid_templates:
- name: 'fiveminutes'
keep_hourly: '24' # Aufheben (Stunde)
keep_daily: '31' # Aufheben (Tage)
keep_monthly: '6' # Aufheben (Monate)
keep_yearly: '0' # Aufheben (Jahre)
frequently: '36' # Aufheben (Minuten)
frequent_period: '5' # Intervall (alle 5 Minuten)
autosnap: 'yes' # Automatisches erstellen von Snapshots
autoprune: 'yes'
- name: 'hourly'
keep_hourly: '24'
keep_daily: '31'
keep_monthly: '6'
keep_yearly: '1'
frequently: '0'
frequent_period: '0'
autosnap: 'yes'
autoprune: 'yes'
### mgrote.smart ### mgrote.smart
smart_smartctlmail_cron_minutes: "15" smart_smartctlmail_cron_minutes: "15"
smart_smartctlmail_cron_hours: "6" smart_smartctlmail_cron_hours: "6"
@ -29,10 +52,34 @@
NOLOGON: disable NOLOGON: disable
### mgrote.zfs_tools ### mgrote.zfs_tools
zfs_arc_max: "12884901888" zfs_arc_max: "12884901888"
zfs_pool: zfs_pools:
- { name: "ssd_vm_mirror", type: "ssd", cron_minute_zfs_trim: "5", cron_hour_zfs_trim: "22", cron_month_zfs_trim: "4,8,12", cron_day_zfs_trim: "2", cron_weekday_zfs_scrub: "6", cron_minutes_zfs_scrub: "0", cron_hour_zfs_scrub: "23"} - name: "ssd_vm_mirror"
- { name: "hdd_vm_mirror", type: "hdd", cron_minute_zfs_trim: "5", cron_hour_zfs_trim: "23", cron_month_zfs_trim: "4,8,12", cron_day_zfs_trim: "2", cron_weekday_zfs_scrub: "6", cron_minutes_zfs_scrub: "0", cron_hour_zfs_scrub: "22"} type: "ssd"
- { name: "hdd_data_raidz", type: "hdd", cron_minute_zfs_trim: "5", cron_hour_zfs_trim: "24", cron_month_zfs_trim: "4,8,12", cron_day_zfs_trim: "2", cron_weekday_zfs_scrub: "6", cron_minutes_zfs_scrub: "0", cron_hour_zfs_scrub: "23"} cron_minute_zfs_trim: "5"
cron_hour_zfs_trim: "22"
cron_month_zfs_trim: "4,8,12"
cron_day_zfs_trim: "2"
cron_weekday_zfs_scrub: "6"
cron_minutes_zfs_scrub: "0"
cron_hour_zfs_scrub: "23"
- name: "hdd_vm_mirror"
type: "hdd"
cron_minute_zfs_trim: "5"
cron_hour_zfs_trim: "23"
cron_month_zfs_trim: "4,8,12"
cron_day_zfs_trim: "2"
cron_weekday_zfs_scrub: "6"
cron_minutes_zfs_scrub: "0"
cron_hour_zfs_scrub: "22"
- name: "hdd_data_raidz"
type: "hdd"
cron_minute_zfs_trim: "5"
cron_hour_zfs_trim: "24"
cron_month_zfs_trim: "4,8,12"
cron_day_zfs_trim: "2"
cron_weekday_zfs_scrub: "6"
cron_minutes_zfs_scrub: "0"
cron_hour_zfs_scrub: "23"
### mgrote.cv4pve-autosnap ### mgrote.cv4pve-autosnap
cv4pve_api_user: root@pam!cv4pve-autosnap cv4pve_api_user: root@pam!cv4pve-autosnap
cv4pve_api_token: "{{ lookup('keepass', 'cv4pve_api_token', 'password') }}" cv4pve_api_token: "{{ lookup('keepass', 'cv4pve_api_token', 'password') }}"

View file

@ -31,3 +31,23 @@ Es sind keine "defaults" gesetzt!
- { freigabename: 'Backup', ordnername: 'Backup', base_folder: '/shares', lese_nutzer: '', schreibe_nutzer: 'annemariedroessler mg restic toolserver win10' } - { freigabename: 'Backup', ordnername: 'Backup', base_folder: '/shares', lese_nutzer: '', schreibe_nutzer: 'annemariedroessler mg restic toolserver win10' }
##### Welche "Arbeitsgruppe" ##### Welche "Arbeitsgruppe"
smb_workgroup: WORKGROUP smb_workgroup: WORKGROUP
## Alternatives Dictionary Format:
```bash
zfs_pools:
- name: "ssd_vm_mirror"
type: "ssd"
cron_minute_zfs_trim: "5"
cron_hour_zfs_trim: "22"
cron_month_zfs_trim: "4,8,12"
cron_day_zfs_trim: "2"
cron_weekday_zfs_scrub: "6"
cron_minutes_zfs_scrub: "0"
cron_hour_zfs_scrub: "23"
```
ist das gleiche wie:
```bash
zfs_pools:
- { name: "ssd_vm_mirror", type: "ssd", cron_minute_zfs_trim: "5", cron_hour_zfs_trim: "22", cron_month_zfs_trim: "4,8,12", cron_day_zfs_trim: "2", cron_weekday_zfs_scrub: "6", cron_minutes_zfs_scrub: "0", cron_hour_zfs_scrub: "23"}
```

View file

@ -1,34 +1,43 @@
--- ---
# Wann soll das sanoid-script mit cron ausgeführt werden? (Stunden) # Wann soll das sanoid-script mit cron ausgeführt werden?
sanoid_cron_hours: '*' sanoid_cron_hours: '*'
# Wann soll das sanoid-script mit cron ausgeführt werden? (Minuten)
sanoid_cron_minutes: '*' sanoid_cron_minutes: '*'
### Definition der Variablen für die sanoid-templates-
# template_fiveminutes
sanoid_template_fiveminutes_snapshot_keep_hourly: '24' # Aufheben (Stunde)
sanoid_template_fiveminutes_snapshot_keep_daily: '31' # Aufheben (Tage)
sanoid_template_fiveminutes_snapshot_keep_monthly: '6' # Aufheben (Monate)
sanoid_template_fiveminutes_snapshot_keep_yearly: '0' # Aufheben (Jahre)
sanoid_template_fiveminutes_snapshot_interval_underhour: '5' # Intervall (alle 5 Minuten)
sanoid_template_fiveminutes_snapshot_keep_underhour: '36' # Aufheben (Minuten)
sanoid_template_fiveminutes_auto_snap: 'yes' # Automatisches erstellen von Snapshots
sanoid_template_fiveminutes_prune: 'yes' # Automatisches Löschen/Prunen alter Snapshots
# template_hourly
sanoid_template_hourly_snapshot_keep_hourly: '24'
sanoid_template_hourly_snapshot_keep_daily: '31'
sanoid_template_hourly_snapshot_keep_monthly: '6'
sanoid_template_hourly_snapshot_keep_yearly: '1'
sanoid_template_hourly_auto_snap: 'yes'
sanoid_template_hourly_prune: 'yes'
# template_daily
sanoid_template_daily_snapshot_keep_daily: '31'
sanoid_template_daily_snapshot_keep_monthly: '6'
sanoid_template_daily_snapshot_keep_yearly: '1'
sanoid_template_daily_auto_snap: 'yes'
sanoid_template_daily_prune: 'yes'
### "Default" Datasets ### "Default" Datasets
sanoid_datasets: sanoid_datasets:
- { path: 'hdd_data_raidz/data', template: 'fiveminutes', recursive: ' no' } - path: 'hdd_data_raidz/data'
- { path: 'hdd_data_raidz/videos', template: 'hourly', recursive: ' yes' } template: 'fiveminutes'
recursive: ' no'
- path: 'hdd_data_raidz/videos'
template: 'hourly'
recursive: ' yes'
### Templates
sanoid_templates:
- name: 'fiveminutes'
keep_hourly: '24' # Aufheben (Stunde)
keep_daily: '31' # Aufheben (Tage)
keep_monthly: '6' # Aufheben (Monate)
keep_yearly: '0' # Aufheben (Jahre)
frequently: '36' # Aufheben (Minuten)
frequent_period: '5' # Intervall (alle 5 Minuten)
autosnap: 'yes' # Automatisches erstellen von Snapshots
autoprune: 'yes'
- name: 'hourly'
keep_hourly: '24'
keep_daily: '31'
keep_monthly: '6'
keep_yearly: '1'
frequently: '0'
frequent_period: '0'
autosnap: 'yes'
autoprune: 'yes'
- name: 'daily'
keep_hourly: '0'
keep_daily: '31'
keep_monthly: '6'
keep_yearly: '1'
frequently: '0'
frequent_period: '0'
autosnap: 'yes'
autoprune: 'yes'

View file

@ -1,40 +1,26 @@
## ZFS Section ## ## ZFS Section -------------------------------- ##
{% for item in sanoid_datasets %} {% for item in sanoid_datasets %}
[{{ item.path }}] [{{ item.path }}]
use_template = {{ item.template }} use_template = {{ item.template }}
recursive = {{ item.recursive }} recursive = {{ item.recursive }}
## ----------- ## ## -------------------------------------------- ##
{% endfor %} {% endfor %}
## Template Section ## ## Template Section --------------------------- ##
[template_fiveminutes] {% for item in sanoid_templates %}
[template_{{ item.name }}]
## Keep-Rules ## Keep-Rules
hourly = {{ sanoid_template_fiveminutes_snapshot_keep_hourly }} hourly = {{ item.keep_hourly }}
daily = {{ sanoid_template_fiveminutes_snapshot_keep_daily }} daily = {{ item.keep_daily }}
monthly = {{ sanoid_template_fiveminutes_snapshot_keep_monthly }} monthly = {{ item.keep_monthly }}
yearly = {{ sanoid_template_fiveminutes_snapshot_keep_yearly }} yearly = {{ item.keep_yearly }}
frequently = {{ sanoid_template_fiveminutes_snapshot_keep_underhour }} frequently = {{ item.frequently }}
## Underhour intervall ## Interval
frequent_period = {{ sanoid_template_fiveminutes_snapshot_interval_underhour }} frequent_period = {{ item.frequent_period }}
## Other Options ## Other Options
autosnap = {{ sanoid_template_fiveminutes_auto_snap }} autosnap = {{ item.autosnap }}
autoprune = {{ sanoid_template_fiveminutes_prune }} autoprune = {{ item.autoprune }}
[template_hourly] ## -------------------------------------------- ##
## Keep-Rules {% endfor %}
hourly = {{ sanoid_template_hourly_snapshot_keep_hourly }}
daily = {{ sanoid_template_hourly_snapshot_keep_daily }}
monthly = {{ sanoid_template_hourly_snapshot_keep_monthly }}
yearly = {{ sanoid_template_hourly_snapshot_keep_yearly }}
## Other Options
autosnap = {{ sanoid_template_hourly_auto_snap }}
autoprune = {{ sanoid_template_hourly_prune }}
[template_daily]
## Keep-Rules
daily = {{ sanoid_template_daily_snapshot_keep_daily }}
monthly = {{ sanoid_template_daily_snapshot_keep_monthly }}
yearly = {{ sanoid_template_daily_snapshot_keep_yearly }}
## Other Options
autosnap = {{ sanoid_template_daily_auto_snap }}
autoprune = {{ sanoid_template_daily_prune }}

View file

@ -14,7 +14,7 @@ Deaktiviert das mitinstallierte scrub-Script in /etc/cron.d/zfsutils-linux.
### Variablen + Defaults ### Variablen + Defaults
##### Wer soll die Mails bekommen ##### Wer soll die Mails bekommen
empfaenger_mail: michael.grote@posteo.de empfaenger_mail: michael.grote@posteo.de
zfs_pool: zfs_vm_mirror zfs_pools: zfs_vm_mirror
##### Maximale Groesse ARC in Bytes ##### Maximale Groesse ARC in Bytes
Beim aendern wird die Zeile einmal mit dem alten Wert und dem neuen Wert in die Zeile eingefuegt! Beim aendern wird die Zeile einmal mit dem alten Wert und dem neuen Wert in die Zeile eingefuegt!
zfs_arc_max: "8589934592" zfs_arc_max: "8589934592"

View file

@ -52,7 +52,7 @@
weekday: "{{ item.cron_weekday_zfs_scrub }}" weekday: "{{ item.cron_weekday_zfs_scrub }}"
minute: "{{ item.cron_minutes_zfs_scrub }}" minute: "{{ item.cron_minutes_zfs_scrub }}"
hour: "{{ item.cron_hour_zfs_scrub }}" hour: "{{ item.cron_hour_zfs_scrub }}"
with_items: "{{ zfs_pool }}" with_items: "{{ zfs_pools }}"
- name: lege cronjob fuer "zfs-trim" an - name: lege cronjob fuer "zfs-trim" an
become: yes become: yes
@ -66,7 +66,7 @@
day: "{{ item.cron_day_zfs_trim }}" day: "{{ item.cron_day_zfs_trim }}"
# disabled: yes # disabled: yes
when: item.type == 'ssd' when: item.type == 'ssd'
with_items: "{{ zfs_pool }}" with_items: "{{ zfs_pools }}"
- name: kopiere zed.rc - name: kopiere zed.rc
become: yes become: yes