systemd: ignore errors in daemon_reload and daemon_reexec when running in a chroot or with $SYSTEMD_OFFLINE==1 (#79643)

Signed-off-by: Olaf Klischat <olaf.klischat@gmail.com>
pull/79698/head
Olaf Klischat 2 years ago committed by GitHub
parent 1375861ec2
commit 32c5793de5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- systemd - daemon-reload and daemon-reexec ignore errors when running in a chroot (https://github.com/ansible/ansible/pull/79643)

@ -391,13 +391,19 @@ def main():
if module.params['daemon_reload'] and not module.check_mode: if module.params['daemon_reload'] and not module.check_mode:
(rc, out, err) = module.run_command("%s daemon-reload" % (systemctl)) (rc, out, err) = module.run_command("%s daemon-reload" % (systemctl))
if rc != 0: if rc != 0:
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err)) if is_chroot(module) or os.environ.get('SYSTEMD_OFFLINE') == '1':
module.warn('daemon-reload failed, but target is a chroot or systemd is offline. Continuing. Error was: %d / %s' % (rc, err))
else:
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err))
# Run daemon-reexec # Run daemon-reexec
if module.params['daemon_reexec'] and not module.check_mode: if module.params['daemon_reexec'] and not module.check_mode:
(rc, out, err) = module.run_command("%s daemon-reexec" % (systemctl)) (rc, out, err) = module.run_command("%s daemon-reexec" % (systemctl))
if rc != 0: if rc != 0:
module.fail_json(msg='failure %d during daemon-reexec: %s' % (rc, err)) if is_chroot(module) or os.environ.get('SYSTEMD_OFFLINE') == '1':
module.warn('daemon-reexec failed, but target is a chroot or systemd is offline. Continuing. Error was: %d / %s' % (rc, err))
else:
module.fail_json(msg='failure %d during daemon-reexec: %s' % (rc, err))
if unit: if unit:
found = False found = False

Loading…
Cancel
Save