diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-13 12:59:43 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-13 14:23:37 +0100 |
commit | fe040d1aa9a01e14c882ead7cb09303aef588804 (patch) | |
tree | 318e6cdff8aa9138866fc1f0140e37347fe7bf66 /manifests/os | |
parent | Safeguard machined fact. (diff) | |
download | nspawn-fe040d1aa9a01e14c882ead7cb09303aef588804.tar.gz nspawn-fe040d1aa9a01e14c882ead7cb09303aef588804.tar.xz |
Rewrote mots of nspawn.
Diffstat (limited to '')
-rw-r--r-- | manifests/os/debian.pp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/manifests/os/debian.pp b/manifests/os/debian.pp index fbab9ac..ff687dd 100644 --- a/manifests/os/debian.pp +++ b/manifests/os/debian.pp @@ -1,21 +1,26 @@ +# TODO rename this to image-setup define nspawn::os::debian ( String $os_version, String $machine = $name, ) { + $root = "/var/lib/machines/debian-${os_version}.base" + ensure_packages(['debootstrap']) - exec { "/usr/bin/deboostrap ${os_version} /var/lib/machines/${machine}": - creates => "/var/lib/machines/${machine}/etc/os-release", + exec { "/usr/bin/deboostrap ${os_version} '${root}'": + creates => "${root}/etc/os-release", } - $puppet_deb = "/var/lib/machines/${machine}/tmp/puppet7-release-${os_version}.deb" - file { $puppet_deb: + $puppet_deb = "puppet7-release-${os_version}.deb" + $puppet_deb_path = "${root}/opt/${puppet_deb}" + + file { $puppet_deb_path: ensure => file, - source => "https://apt.puppet.com/puppet7-release-${os_version}.deb" + source => "https://apt.puppet.com/${puppet_deb}" } - $running = $facts['machined-info'][$machine] != Undef or $facts['machined-info'][$machine]['State'] == 'running' + $running = $facts['machined-info'][$machine] != undef and $facts['machined-info'][$machine]['State'] == 'running' if $running { # TODO @@ -24,12 +29,12 @@ define nspawn::os::debian ( } } else { exec { "Set up puppet repo for ${machine}": - subscribe => File[$puppet_deb], + subscribe => File[$puppet_deb_path], command => [ '/usr/bin/systemd-nspawn', '-M', $machine, '--quiet', '/bin/sh', '-c', - "dpkg -i '/tmp/puppet7-release-${os_version}.deb' && apt update" + "dpkg -i '/opt/puppet7-release-${os_version}.deb' && apt update" ], } @@ -39,11 +44,28 @@ define nspawn::os::debian ( '--quiet', 'apt', 'install', 'puppet-agent', ], - creates => "/var/lib/machines/${machine}/opt/puppetlabs/bin/puppet", + creates => "${root}/opt/puppetlabs/bin/puppet", } } + + exec { "Enable puppet on ${machine}": + command => [ '/usr/bin/systemd-nspawn', + '-M', $machine, + '--quiet', + 'systemctl', 'enable', 'puppet', + ], + creates => "${root}/etc/systemd/system/multi-user.target.wants/puppet.service", + } + + file { "${root}/etc/puppetlabs/puppet/puppet.conf": + ensure => file, + content => @(EOF) + [main] + server = busting.adrift.space + | EOF + } + nspawn::util::disable_networking { $machine: } nspawn::util::enable_networkd { $machine: } - } |