summaryrefslogtreecommitdiff
path: root/manifests
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
commitd187e5a2c83b07a2214f7890191d9bdb0699b3fb (patch)
treeb2a05526123ddfa38d28f51a3ce970079438206e /manifests
downloadsystemd_mount-d187e5a2c83b07a2214f7890191d9bdb0699b3fb.tar.gz
systemd_mount-d187e5a2c83b07a2214f7890191d9bdb0699b3fb.tar.xz
Migrate stuff from ansible.
Diffstat (limited to 'manifests')
-rw-r--r--manifests/init.pp42
1 files changed, 42 insertions, 0 deletions
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,
+ }
+ }
+
+}