diff options
Diffstat (limited to 'modules/nspawn/manifests/util/disable_networking.pp')
-rw-r--r-- | modules/nspawn/manifests/util/disable_networking.pp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/nspawn/manifests/util/disable_networking.pp b/modules/nspawn/manifests/util/disable_networking.pp new file mode 100644 index 0000000..4a9b31b --- /dev/null +++ b/modules/nspawn/manifests/util/disable_networking.pp @@ -0,0 +1,22 @@ +define nspawn::util::disable_networking ( + String $machine = $name, + String $machine_path = "/var/lib/machines/${machine}", +) { + + + $cmd = if $facts['machined-info'][$machine]['State'] == 'running' { + [ 'systemctl', '-M', $machine, 'disable', 'networking' ] + } else { + [ 'systemd-nspawn', '-M', $machine, '--quiet', + 'systemctl', 'disable', 'networking' ] + } + + exec { "Disable networking on ${machine}": + command => $cmd, + path => [ '/bin', '/usr/bin', ], + # among others + # creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service", + } + +} + |