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", } }