summaryrefslogtreecommitdiff
path: root/manifests/init.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/init.pp')
-rw-r--r--manifests/init.pp45
1 files changed, 45 insertions, 0 deletions
diff --git a/manifests/init.pp b/manifests/init.pp
new file mode 100644
index 0000000..3eedbae
--- /dev/null
+++ b/manifests/init.pp
@@ -0,0 +1,45 @@
+# @summary Configures systemd nspawn containers
+# @param config
+# Shared configuration for all machines, as per systemd.nspawn(5).
+#
+# See nspawn::machine's documentation for how it's merged.
+#
+# @param machines
+# Set of machines to be configured. Creates `nspawn::machine` resources.
+# See that resource type for acceptable options.
+#
+# @param template_dir
+# Location of template subvolumes.
+#
+# @param purge
+# Should old .nspawn files be purged.
+class nspawn (
+ Nspawn::Systemdconfig $config,
+ Stdlib::Abspath $template_dir = '/var/lib/templates',
+ Hash[String, Hash[String, Any]] $machines = {},
+ Boolean $purge = true,
+) {
+ # These aren't parameters since they aren't configurable.
+ # However, move them to the parameters if it turns out that
+ # different distributions place these files in different places.
+ # Location of nspawn files.
+ $nspawn_dir = '/etc/systemd/nspawn'
+ # Location of machine subvolumes.
+ $machine_dir = '/var/lib/machines'
+
+ file { $nspawn_dir:
+ ensure => directory,
+ purge => $purge,
+ recurse => true,
+ }
+
+ file { $template_dir:
+ ensure => directory,
+ }
+
+ file { $machine_dir:
+ ensure => directory,
+ }
+
+ create::resources('nspawn::machine', $machines)
+}