From c7f59cec7f0f421b431afb086557a5344b72295d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sat, 15 Jan 2022 12:07:57 +0100 Subject: Fix nspawn continious exec:s. --- manifests/os/debian.pp | 5 +++-- 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", - } - } -- cgit v1.2.3