From 14cc76fa1b083f65103beec77232b34459f5efbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 2 Jan 2022 02:42:48 +0100 Subject: Only run nspawn stuff if machine not running. --- manifests/os/arch.pp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'manifests/os/arch.pp') diff --git a/manifests/os/arch.pp b/manifests/os/arch.pp index 5fbf5d1..0affee1 100644 --- a/manifests/os/arch.pp +++ b/manifests/os/arch.pp @@ -20,14 +20,19 @@ define nspawn::os::arch ( | EOF } - exec { "Enable systemd-networkd on ${machine}": - command => [ '/usr/bin/systemd-nspawn', - '-M', $machine, - '--quiet', - 'systemctl', 'enable', 'systemd-networkd', - ], - # among others - creates => "/var/lib/machines/${machine}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service", + if $facts['machined-info'][$machine]['State'] == 'running' { + notify { "Notify skipping ${machine} setup": + message => "Skipping setup for ${machine}, already running", + } + } else { + exec { "Enable systemd-networkd on ${machine}": + command => [ '/usr/bin/systemd-nspawn', + '-M', $machine, + '--quiet', + 'systemctl', 'enable', 'systemd-networkd', + ], + # among others + creates => "/var/lib/machines/${machine}/etc/systemd/system/multi-user.target.wants/systemd-networkd.service", + } } - } -- cgit v1.2.3