summaryrefslogtreecommitdiff
path: root/modules/systemd_mount
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-12-14 00:58:22 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-12-14 02:16:16 +0100
commite3c15ec94649c7ba079c3332fc4afc5bda0b4b5a (patch)
tree215c9048c49c5fbcab9484893024b0bd42f74d9f /modules/systemd_mount
parentMerge branch 'raspi' (diff)
downloadwebdav_server-e3c15ec94649c7ba079c3332fc4afc5bda0b4b5a.tar.gz
webdav_server-e3c15ec94649c7ba079c3332fc4afc5bda0b4b5a.tar.xz
Migrate stuff from ansible.
Diffstat (limited to '')
-rw-r--r--modules/systemd_mount/manifests/init.pp42
-rw-r--r--modules/systemd_mount/templates/automount.epp11
-rw-r--r--modules/systemd_mount/templates/mount.epp13
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 %>