diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-14 00:58:22 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2021-12-14 02:16:16 +0100 |
commit | e3c15ec94649c7ba079c3332fc4afc5bda0b4b5a (patch) | |
tree | 215c9048c49c5fbcab9484893024b0bd42f74d9f /modules/systemd | |
parent | Merge branch 'raspi' (diff) | |
download | webdav_server-e3c15ec94649c7ba079c3332fc4afc5bda0b4b5a.tar.gz webdav_server-e3c15ec94649c7ba079c3332fc4afc5bda0b4b5a.tar.xz |
Migrate stuff from ansible.
Diffstat (limited to '')
-rw-r--r-- | modules/systemd_mount/manifests/init.pp | 42 | ||||
-rw-r--r-- | modules/systemd_mount/templates/automount.epp | 11 | ||||
-rw-r--r-- | modules/systemd_mount/templates/mount.epp | 13 |
3 files changed, 66 insertions, 0 deletions
diff --git a/modules/systemd_mount/manifests/init.pp b/modules/systemd_mount/manifests/init.pp new file mode 100644 index 0000000..ff081e4 --- /dev/null +++ b/modules/systemd_mount/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/modules/systemd_mount/templates/automount.epp b/modules/systemd_mount/templates/automount.epp new file mode 100644 index 0000000..c65f2ae --- /dev/null +++ b/modules/systemd_mount/templates/automount.epp @@ -0,0 +1,11 @@ +<%- | String $where, + String $wantedBy, +| -%> + +[Unit] + +[Install] +<%= $wantedBy %> + +[Automount] +Where=<%= $where %> diff --git a/modules/systemd_mount/templates/mount.epp b/modules/systemd_mount/templates/mount.epp new file mode 100644 index 0000000..54d191a --- /dev/null +++ b/modules/systemd_mount/templates/mount.epp @@ -0,0 +1,13 @@ +<%- | String $where, + String $what, + String $wantedby, +| -%> + +[Unit] + +[Install] +<%= $wantedby %> + +[Mount] +Where=<%= $where %> +What=<%= $what %> |