From 955de3446d61e580ce55d245c0efc900dae019da Mon Sep 17 00:00:00 2001 From: Thomas Bellman <bellman@lysator.liu.se> Date: Mon, 4 Oct 2021 18:10:13 +0200 Subject: [PATCH] Move directory paths to separate class. This adds the semi-internal class 'systemd::vars' containing various paths and other constants for use in the rest of the module, so we won't need to repeat ourselves. Currently only contains a single variable, $etcdir, pointing to /etc/systemd/system. --- manifests/unit_options.pp | 6 +++--- manifests/vars.pp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 manifests/vars.pp diff --git a/manifests/unit_options.pp b/manifests/unit_options.pp index 91fa8db..6989b48 100644 --- a/manifests/unit_options.pp +++ b/manifests/unit_options.pp @@ -57,6 +57,7 @@ define systemd::unit_options( $ensure='present', ) { + include systemd::vars include systemd::daemon_reload if ($name =~ /^([^\/.]+)\.([^\/.]+)\/(.+)$/) { @@ -69,8 +70,7 @@ define systemd::unit_options( " ``${name}''") } - $etcdir = '/etc/systemd/system' - $unitdir = "${etcdir}/${unitname}.${unittype}.d" + $unitdir = "${systemd::vars::etcdir}/${unitname}.${unittype}.d" $filepath = "${unitdir}/${filename}.conf" case $ensure @@ -78,7 +78,7 @@ define systemd::unit_options( 'present': { cfgfile::directory_parents { $filepath: - top => $etcdir, + top => $systemd::vars::etcdir, owner => 'root', group => 'root', mode => '0755'; } file { diff --git a/manifests/vars.pp b/manifests/vars.pp new file mode 100644 index 0000000..890a89c --- /dev/null +++ b/manifests/vars.pp @@ -0,0 +1,12 @@ +# Copyright © 2021 Thomas Bellman, Linköping, Sweden +# Licensed under the GNU LGPL v3+; see the README file for more information. + + +/* + * Various constants (file paths, et.c). Not overridable by users. + * Mostly intended for internal use. + */ +class systemd::vars +{ + $etcdir = '/etc/systemd/system' +} -- GitLab