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
|
define nspawn::util::disable_networking (
String $template_name = $name,
String $template_dir = $nspawn::template_dir,
String $template_path = "${template_dir}/${template_name}.base",
) {
$running = $facts['machined-info'][$template_name] != undef
and $facts['machined-info'][$template_name]['State'] == 'running'
$cmd = if $running {
[ 'systemctl', '-M', $template_name, 'disable', 'networking' ]
} else {
[ 'systemd-nspawn', '-M', $template_name, '--quiet',
'systemctl', 'disable', 'networking' ]
}
exec { "Disable networking on ${template_name}":
command => $cmd,
path => [ '/bin', '/usr/bin', ],
# among others
# creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
}
}
|