From b26b8e0a686c6fbd9a777120537def1015a074fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 1 Jan 2022 23:00:13 +0100 Subject: Setup nspawn? --- manifests/os/debian.pp | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 manifests/os/debian.pp (limited to 'manifests/os/debian.pp') diff --git a/manifests/os/debian.pp b/manifests/os/debian.pp new file mode 100644 index 0000000..c821ba6 --- /dev/null +++ b/manifests/os/debian.pp @@ -0,0 +1,61 @@ +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", + } + + file { "/var/lib/machines/${machine}/etc/network/interfaces": + ensure => file, + content => @(EOF) + # File managed by puppet + # See interfaces(5) + source-directory /etc/network/interfaces.d + | EOF + } + + file { "/var/lib/machines/${machine}/etc/network/interfaces.d": + ensure => directory, + } + + file { "/var/lib/machines/${machine}/etc/network/interfaces.d/puppet": + ensure => file, + content => @(EOF) + # File managed by puppet + auto host0 + # allow-hotplug host0 + + iface host0 inet static + address 10.0.0.42/23 + gateway 10.0.0.1 + + iface host0 inet6 auto + private 0 + | EOF + } + + file { "/var/lib/machines/${machine}/tmp/puppet7-release/${os_version}.deb": + ensure => file, + source => "https://apt.puppet.com/puppet7-release-${os_version}.deb" + } + ~> exec { "Set up puppet repo for ${machine}": + 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", + } +} -- cgit v1.2.3