diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-15 12:07:57 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-01-15 12:08:40 +0100 |
commit | c7f59cec7f0f421b431afb086557a5344b72295d (patch) | |
tree | 59cd2f39a2294b7a2f24af27a38edd2cd77cec19 | |
parent | Nspawn cleanup. (diff) | |
download | nspawn-c7f59cec7f0f421b431afb086557a5344b72295d.tar.gz nspawn-c7f59cec7f0f421b431afb086557a5344b72295d.tar.xz |
Fix nspawn continious exec:s.
-rw-r--r-- | manifests/os/debian.pp | 5 | ||||
-rw-r--r-- | manifests/util/disable_networking.pp | 24 |
2 files changed, 9 insertions, 20 deletions
diff --git a/manifests/os/debian.pp b/manifests/os/debian.pp index e7e7a21..9e42737 100644 --- a/manifests/os/debian.pp +++ b/manifests/os/debian.pp @@ -32,8 +32,9 @@ define nspawn::os::debian ( } } else { exec { "Set up puppet repo for ${template_name}": - subscribe => File[$puppet_deb_path], - command => [ '/usr/bin/systemd-nspawn', + subscribe => File[$puppet_deb_path], + refreshonly => true, + command => [ '/usr/bin/systemd-nspawn', '-M', $template_name, '--quiet', '/bin/sh', '-c', diff --git a/manifests/util/disable_networking.pp b/manifests/util/disable_networking.pp index 22d431f..186d096 100644 --- a/manifests/util/disable_networking.pp +++ b/manifests/util/disable_networking.pp @@ -1,25 +1,13 @@ define nspawn::util::disable_networking ( String $template_name = $name, String $template_dir = $nspawn::template_dir, - String $template_path = "${template_dir}/${template_name}.base", + String $template_path = "${template_dir}/${template_name}", ) { - - $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' ] + # Manually masking instead of trying to disable/mask it through + # systemd, since this is MUCH easier to do whith puppet. + file { "${template_path}/etc/systemd/system/networking.service": + ensure => link, + target => '/dev/null', } - - 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", - } - } |