define nspawn::util::enable_networkd ( String $template_name = $name, String $template_dir = $nspawn::template_dir, String $root = "${template_dir}/${template_name}", ) { networking::networkd_instance { "Initial networking on ${template_name}": priority => 99, filename => 'puppet-initial', path => "${root}/${networking::networkd::path}", content => { 'Match' => { 'Name' => 'host0', }, 'Network' => { 'DHCP' => 'ipv4', 'IPv6AcceptRA' => 1, }, }, } $running = $facts['machined-info'][$template_name] != undef and $facts['machined-info'][$template_name]['State'] == 'running' $cmd = if $running { [ 'systemctl', '-M', $template_name, 'enable', 'systemd-networkd' ] } else { [ 'systemd-nspawn', '-M', $template_name, '--quiet', 'systemctl', 'enable', 'systemd-networkd' ] } exec { "Enable systemd-networkd on ${template_name}": command => $cmd, path => [ '/bin', '/usr/bin', ], # among others creates => "${root}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service", } }