From 8ef18839a6c8ffda1711223bcc4479131d7e632d Mon Sep 17 00:00:00 2001 From: Susant Sahani Date: Sat, 22 Sep 2018 11:43:33 +0530 Subject: [PATCH] Add `systemctl daemon-reexec` to `systemd` module ``` - name: systemctl daemon-reexec - systemd: daemon_reexec=yes ``` Closes: #38880 Signed-off-by: Susant Sahani --- lib/ansible/modules/system/systemd.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/ansible/modules/system/systemd.py b/lib/ansible/modules/system/systemd.py index 37a9e55a958..47583ad1c44 100644 --- a/lib/ansible/modules/system/systemd.py +++ b/lib/ansible/modules/system/systemd.py @@ -48,6 +48,13 @@ options: type: bool default: 'no' aliases: [ daemon-reload ] + daemon_reexec: + description: + - run daemon_reexec command before doing any other operations, the systemd manager will serialize the manager state. + type: bool + default: 'no' + aliases: [ daemon-reexec ] + version_added: "2.8" user: description: - (deprecated) run ``systemctl`` talking to the service manager of the calling user, rather than the service manager @@ -306,6 +313,7 @@ def main(): force=dict(type='bool'), masked=dict(type='bool'), daemon_reload=dict(type='bool', default=False, aliases=['daemon-reload']), + daemon_reexec=dict(type='bool', default=False, aliases=['daemon-reexec']), user=dict(type='bool'), scope=dict(type='str', choices=['system', 'user', 'global']), no_block=dict(type='bool', default=False), @@ -356,6 +364,12 @@ def main(): if rc != 0: module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err)) + # Run daemon-reexec + if module.params['daemon_reexec'] and not module.check_mode: + (rc, out, err) = module.run_command("%s daemon-reexec" % (systemctl)) + if rc != 0: + module.fail_json(msg='failure %d during daemon-reexec: %s' % (rc, err)) + if unit: found = False is_initd = sysv_exists(unit)