From 3382a24498bc591ffe7a1034b1c8b113fd0c76cf Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 14 Aug 2017 13:58:25 -0700 Subject: [PATCH] Fix systemctl command (#1478247) When multiple units are passed to systemctl and one fails it doesn't finish the others. Change the template command to call systemctl for each unit individually. This also removes the lvm2-activation-generator in runtime-cleanup.tmpl --- .../99-generic/runtime-postinstall.tmpl | 3 +++ src/pylorax/ltmpl.py | 15 ++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/share/templates.d/99-generic/runtime-postinstall.tmpl b/share/templates.d/99-generic/runtime-postinstall.tmpl index a901fe1d..53e99cb7 100644 --- a/share/templates.d/99-generic/runtime-postinstall.tmpl +++ b/share/templates.d/99-generic/runtime-postinstall.tmpl @@ -47,6 +47,9 @@ systemctl mask fedora-configure.service fedora-loadmodules.service \ systemd-tmpfiles-clean.service systemd-tmpfiles-clean.timer \ ldconfig.service +## remove because it cannot be disabled +remove usr/lib/systemd/system-generators/lvm2-activation-generator + ## Remove the more terrible parts of systemd-tmpfiles. ## etc.conf is written with the assumption that /etc/ is empty, which is ## ridiculous, and it also creates a broken /etc/resolv.conf, which breaks diff --git a/src/pylorax/ltmpl.py b/src/pylorax/ltmpl.py index 37877e61..293258fe 100644 --- a/src/pylorax/ltmpl.py +++ b/src/pylorax/ltmpl.py @@ -775,11 +775,12 @@ class LoraxTemplateRunner(object): logger.debug("systemctl: no units given for %s, ignoring", cmd) return self.mkdir("/run/systemd/system") # XXX workaround for systemctl bug - systemctl = ('systemctl', '--root', self.outroot, '--no-reload', - '--quiet', cmd) + systemctl = ['systemctl', '--root', self.outroot, '--no-reload', cmd] + # When a unit doesn't exist systemd aborts the command. Run them one at a time. # XXX for some reason 'systemctl enable/disable' always returns 1 - try: - cmd = systemctl + units - runcmd(cmd) - except CalledProcessError: - pass + for unit in units: + try: + cmd = systemctl + [unit] + runcmd(cmd) + except CalledProcessError: + pass