From dfa81fe29a6be169d6ed2803c4bedcd211b16d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 13 Jan 2022 23:15:11 +0100 Subject: Nspawn cleanup. --- manifests/util/disable_networking.pp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'manifests/util/disable_networking.pp') diff --git a/manifests/util/disable_networking.pp b/manifests/util/disable_networking.pp index ac55951..22d431f 100644 --- a/manifests/util/disable_networking.pp +++ b/manifests/util/disable_networking.pp @@ -1,18 +1,20 @@ define nspawn::util::disable_networking ( - String $machine = $name, - String $machine_path = "/var/lib/machines/${machine}", + String $template_name = $name, + String $template_dir = $nspawn::template_dir, + String $template_path = "${template_dir}/${template_name}.base", ) { - $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, 'disable', 'networking' ] + [ 'systemctl', '-M', $template_name, 'disable', 'networking' ] } else { - [ 'systemd-nspawn', '-M', $machine, '--quiet', + [ 'systemd-nspawn', '-M', $template_name, '--quiet', 'systemctl', 'disable', 'networking' ] } - exec { "Disable networking on ${machine}": + exec { "Disable networking on ${template_name}": command => $cmd, path => [ '/bin', '/usr/bin', ], # among others -- cgit v1.2.3