summaryrefslogtreecommitdiff
path: root/manifests/util/enable_networkd.pp
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2022-01-13 23:15:11 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2022-01-13 23:53:26 +0100
commitdfa81fe29a6be169d6ed2803c4bedcd211b16d72 (patch)
tree77bd0d72e5fe48e07b5d7be5f7532b776f9c53ba /manifests/util/enable_networkd.pp
parentRewrote mots of nspawn. (diff)
downloadnspawn-dfa81fe29a6be169d6ed2803c4bedcd211b16d72.tar.gz
nspawn-dfa81fe29a6be169d6ed2803c4bedcd211b16d72.tar.xz
Nspawn cleanup.
Diffstat (limited to 'manifests/util/enable_networkd.pp')
-rw-r--r--manifests/util/enable_networkd.pp20
1 files changed, 11 insertions, 9 deletions
diff --git a/manifests/util/enable_networkd.pp b/manifests/util/enable_networkd.pp
index f9b4d2e..40cb3d9 100644
--- a/manifests/util/enable_networkd.pp
+++ b/manifests/util/enable_networkd.pp
@@ -1,12 +1,13 @@
define nspawn::util::enable_networkd (
- String $machine = $name,
- String $machine_path = "/var/lib/machines/${machine}",
+ String $template_name = $name,
+ String $template_dir = $nspawn::template_dir,
+ String $root = "${template_dir}/${template_name}",
) {
- networking::networkd_instance { "Initial networking on ${machine}":
+ networking::networkd_instance { "Initial networking on ${template_name}":
priority => 99,
filename => 'puppet-initial',
- path => "${machine_path}/${networking::networkd::path}",
+ path => "${root}/${networking::networkd::path}",
content => {
'Match' => {
'Name' => 'host0',
@@ -18,20 +19,21 @@ define nspawn::util::enable_networkd (
},
}
- $running = $facts['machined-info'][$machine] != undef and $facts['machined-info'][$machine]['State'] == 'running'
+ $running = $facts['machined-info'][$template_name] != undef
+ and $facts['machined-info'][$template_name]['State'] == 'running'
$cmd = if $running {
- [ 'systemctl', '-M', $machine, 'enable', 'systemd-networkd' ]
+ [ 'systemctl', '-M', $template_name, 'enable', 'systemd-networkd' ]
} else {
- [ 'systemd-nspawn', '-M', $machine, '--quiet',
+ [ 'systemd-nspawn', '-M', $template_name, '--quiet',
'systemctl', 'enable', 'systemd-networkd' ]
}
- exec { "Enable systemd-networkd on ${machine}":
+ exec { "Enable systemd-networkd on ${template_name}":
command => $cmd,
path => [ '/bin', '/usr/bin', ],
# among others
- creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
+ creates => "${root}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
}
}