summaryrefslogtreecommitdiff
path: root/manifests/os/debian.pp
diff options
context:
space:
mode:
Diffstat (limited to 'manifests/os/debian.pp')
-rw-r--r--manifests/os/debian.pp42
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: }
-
}