1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# 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} '${root}'":
creates => "${root}/etc/os-release",
}
$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/${puppet_deb}"
}
$running = $facts['machined-info'][$machine] != undef and $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_path],
command => [ '/usr/bin/systemd-nspawn',
'-M', $machine,
'--quiet',
'/bin/sh', '-c',
"dpkg -i '/opt/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 => "${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: }
}
|