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
|
define nspawn::util::enable_networkd (
String $machine = $name,
String $machine_path = "/var/lib/machines/${machine}",
) {
# TODO only do this if the directory is empty
networking::networkd_instance { "Initial networking on ${machine}":
priority => 50,
filename => 'puppet-initial',
path => "${machine_path}/${networking::networkd::path}",
content => {
'Match' => {
'Name' => 'host0',
},
'Network' => {
'DHCP' => 'ipv4',
'IPv6AcceptRA' => 1,
},
},
}
$running = $facts['machined-info'][$machine] != Undef or $facts['machined-info'][$machine]['State'] == 'running'
$cmd = if $running {
[ 'systemctl', '-M', $machine, 'enable', 'systemd-networkd' ]
} else {
[ 'systemd-nspawn', '-M', $machine, '--quiet',
'systemctl', 'enable', 'systemd-networkd' ]
}
exec { "Enable systemd-networkd on ${machine}":
command => $cmd,
path => [ '/bin', '/usr/bin', ],
# among others
creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
}
}
|