define nspawn::util::disable_networking ( String $template_name = $name, String $template_dir = $nspawn::template_dir, String $template_path = "${template_dir}/${template_name}.base", ) { $running = $facts['machined-info'][$template_name] != undef and $facts['machined-info'][$template_name]['State'] == 'running' $cmd = if $running { [ 'systemctl', '-M', $template_name, 'disable', 'networking' ] } else { [ 'systemd-nspawn', '-M', $template_name, '--quiet', 'systemctl', 'disable', 'networking' ] } exec { "Disable networking on ${template_name}": command => $cmd, path => [ '/bin', '/usr/bin', ], # among others # creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service", } }