From 13c8554d2ca74ecc52a7d7d1a468b5443c717c54 Mon Sep 17 00:00:00 2001 From: mergwyn Date: Sun, 3 Dec 2023 18:25:10 +0000 Subject: [PATCH] Install pyznap rather than zfs-auto-snap --- .../manifests/platform/baseline/debian/zfs.pp | 2 +- .../baseline/debian/zfs/autosnapshot.pp | 7 -- .../baseline/debian/zfs/snapshotter.pp | 68 +++++++++++++++++++ 3 files changed, 69 insertions(+), 8 deletions(-) delete mode 100644 site-modules/profile/manifests/platform/baseline/debian/zfs/autosnapshot.pp create mode 100644 site-modules/profile/manifests/platform/baseline/debian/zfs/snapshotter.pp diff --git a/site-modules/profile/manifests/platform/baseline/debian/zfs.pp b/site-modules/profile/manifests/platform/baseline/debian/zfs.pp index 980f415d..bcf879c6 100644 --- a/site-modules/profile/manifests/platform/baseline/debian/zfs.pp +++ b/site-modules/profile/manifests/platform/baseline/debian/zfs.pp @@ -2,7 +2,7 @@ # class profile::platform::baseline::debian::zfs { - include profile::platform::baseline::debian::zfs::autosnapshot + include profile::platform::baseline::debian::zfs::snapshotter include profile::platform::baseline::debian::zfs::default # include profile::platform::baseline::debian::zfs::grub include profile::platform::baseline::debian::zfs::kernelopts diff --git a/site-modules/profile/manifests/platform/baseline/debian/zfs/autosnapshot.pp b/site-modules/profile/manifests/platform/baseline/debian/zfs/autosnapshot.pp deleted file mode 100644 index 9479af4f..00000000 --- a/site-modules/profile/manifests/platform/baseline/debian/zfs/autosnapshot.pp +++ /dev/null @@ -1,7 +0,0 @@ -# @summary autosnapshot -# -class profile::platform::baseline::debian::zfs::autosnapshot { - - package { 'zfs-auto-snapshot': } - -} diff --git a/site-modules/profile/manifests/platform/baseline/debian/zfs/snapshotter.pp b/site-modules/profile/manifests/platform/baseline/debian/zfs/snapshotter.pp new file mode 100644 index 00000000..cecb746e --- /dev/null +++ b/site-modules/profile/manifests/platform/baseline/debian/zfs/snapshotter.pp @@ -0,0 +1,68 @@ +# @summary zfs snappshotter install and configuration +# +class profile::platform::baseline::debian::zfs::snapshotter ( + String $type = 'pyznap', + $settings = null, +){ + + case $type { + 'pyznap': { + $codedir = '/opt' + $target = "${codedir}/pyznap" + $configdir = '/etc/pyznap' + $target_ini = "${configdir}/pyznap.conf" + + $venv = "${target}/venv" + + $owner = lookup('defaults::media_user') + $group = lookup('defaults::media_group') + $adminemail = lookup('defaults::adminemail') + + python::pip { $type: + ensure => 'present', + pkgname => $type, + pip_provider => 'pip3', + virtualenv => $venv, + owner => $owner, + group => $group, + timeout => 1800 + } + + file { $configdir: + ensure => directory, + owner => $owner, + group => $group, + } + $defaults = { + path => $target_ini, + require => File[ $configdir ], + 'rpool' => { + 'frequent' => '4', + 'hourly' => '24', + 'daily' => '7', + 'weekly' => '4', + 'monthly' => '3', + 'yearly' => '0', + 'snap' => 'no', + 'clean' => 'yes', + }, + 'rpool/ROOT' => { + 'snap' => 'yes', + }, + 'rpool/home' => { + 'snap' => 'yes', + } + } + inifile::create_ini_settings($settings, $defaults) + + package { 'zfs-auto-snapshot': ensure => absent } + } + + + 'zfs-auto-snapshot': { + package { 'zfs-auto-snapshot': } + } + default: { + } + } +}