summaryrefslogtreecommitdiff
path: root/modules/nspawn/manifests/util/disable_networking.pp
blob: 4a9b31b47136fadd7504dc810389a45a61e76b61 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
define nspawn::util::disable_networking (
  String $machine = $name,
  String $machine_path = "/var/lib/machines/${machine}",
) {


  $cmd = if $facts['machined-info'][$machine]['State'] == 'running' {
    [ 'systemctl', '-M', $machine, 'disable', 'networking' ]
  } else {
    [ 'systemd-nspawn', '-M', $machine, '--quiet',
      'systemctl', 'disable', 'networking' ]
  }

  exec { "Disable networking on ${machine}":
    command => $cmd,
    path    => [ '/bin', '/usr/bin', ],
    # among others
    # creates => "${machine_path}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service",
  }

}