define nspawn::os::debian ( String $os_version, String $machine = $name, ) { ensure_packages(['debootstrap']) exec { "/usr/bin/deboostrap ${os_version} /var/lib/machines/${machine}": creates => "/var/lib/machines/${machine}/etc/os-release", } $puppet_deb = "/var/lib/machines/${machine}/tmp/puppet7-release-${os_version}.deb" file { $puppet_deb: ensure => file, source => "https://apt.puppet.com/puppet7-release-${os_version}.deb" } $running = $facts['machined-info'][$machine] != Undef or $facts['machined-info'][$machine]['State'] == 'running' if $running { # TODO notify { "Notify skipping ${machine} setup": message => "Skipping setup for ${machine}, already running", } } else { exec { "Set up puppet repo for ${machine}": subscribe => File[$puppet_deb], command => [ '/usr/bin/systemd-nspawn', '-M', $machine, '--quiet', '/bin/sh', '-c', "dpkg -i '/tmp/puppet7-release-${os_version}.deb' && apt update" ], } exec { "install puppet-agent on ${machine}": command => [ '/usr/bin/systemd-nspawn', '-M', $machine, '--quiet', 'apt', 'install', 'puppet-agent', ], creates => "/var/lib/machines/${machine}/opt/puppetlabs/bin/puppet", } } nspawn::util::disable_networking { $machine: } nspawn::util::enable_networkd { $machine: } }