diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-02 04:31:50 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-02 04:44:39 +0100 |
commit | e3e75161d06387a979b8f4a04f406f9b54f8703e (patch) | |
tree | 85f1917c8ba2f0c416fcd1298d29c41ea0b58918 /manifests/util/disable_networking.pp | |
parent | Move paths. (diff) | |
download | nspawn-e3e75161d06387a979b8f4a04f406f9b54f8703e.tar.gz nspawn-e3e75161d06387a979b8f4a04f406f9b54f8703e.tar.xz |
Network rewrites.
Diffstat (limited to 'manifests/util/disable_networking.pp')
-rw-r--r-- | manifests/util/disable_networking.pp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/manifests/util/disable_networking.pp b/manifests/util/disable_networking.pp new file mode 100644 index 0000000..4a9b31b --- /dev/null +++ b/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", + } + +} + |