summaryrefslogtreecommitdiff
path: root/manifests/init.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2023-06-23 17:33:17 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2023-06-23 17:33:17 +0200
commitaede37be1b70ed4e53081682a6ec4814c348cb49 (patch)
tree3d29d58540a0ec9a71a3894a90268d3be6088a77 /manifests/init.pp
parentRemove everything. (diff)
downloadnspawn-aede37be1b70ed4e53081682a6ec4814c348cb49.tar.gz
nspawn-aede37be1b70ed4e53081682a6ec4814c348cb49.tar.xz
Add new modules content.
This module is designed differently. It makes no attempt to manage templates. It still attempts to manage machines, but this should probably move to Puppet tasks or similar, with the static configuration mostly doing cleanup.
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)
+}