From d187e5a2c83b07a2214f7890191d9bdb0699b3fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 14 Dec 2021 00:58:22 +0100 Subject: Migrate stuff from ansible. --- manifests/init.pp | 42 ++++++++++++++++++++++++++++++++++++++++++ templates/automount.epp | 11 +++++++++++ templates/mount.epp | 13 +++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 manifests/init.pp create mode 100644 templates/automount.epp create mode 100644 templates/mount.epp diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..ff081e4 --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,42 @@ +define systemd_mount ( + String $what, # elrond:/files + String $where, # /usr/net + Boolean $automount = false, + String $wantedBy = 'default.target', +) { + + $mostly_fixed = regsubst($where, '/', '-', 'G') + $fixed = if $mostly_fixed[0] == '-' { + $mostly_fixed[1, -1] # drop first char + } else { + $mostly_fixed + } + + systemd::unit_file { "${fixed}.mount": + content => epp('systemd_mount/mount.epp', { + what => $what, + where => $where, + wantedby => if ($automount) { '' } else { "WantedBy=${wantedBy}" }, + }), + } + + if ($automount) { + systemd::unit_file { "${fixed}.automount": + content => epp('systemd_mount/automount.epp', { + where => $where, + wantedBy => "WantedBy=${wantedBy}", + }), + } + + service { "${fixed}.automount": + enable => true, + ensure => running, + } + } else { + service { "${fixed}.mount": + enable => true, + ensure => running, + } + } + +} diff --git a/templates/automount.epp b/templates/automount.epp new file mode 100644 index 0000000..c65f2ae --- /dev/null +++ b/templates/automount.epp @@ -0,0 +1,11 @@ +<%- | String $where, + String $wantedBy, +| -%> + +[Unit] + +[Install] +<%= $wantedBy %> + +[Automount] +Where=<%= $where %> diff --git a/templates/mount.epp b/templates/mount.epp new file mode 100644 index 0000000..54d191a --- /dev/null +++ b/templates/mount.epp @@ -0,0 +1,13 @@ +<%- | String $where, + String $what, + String $wantedby, +| -%> + +[Unit] + +[Install] +<%= $wantedby %> + +[Mount] +Where=<%= $where %> +What=<%= $what %> -- cgit v1.2.3