mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 07:01:22 -07:00
systemctl show rc changes across versions
to avoid different errors across versions, ignore rc in favor of found/notfound fixes #5710
This commit is contained in:
parent
b264f8c1cd
commit
da9adccb02
1 changed files with 28 additions and 31 deletions
|
@ -272,15 +272,13 @@ def main():
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err))
|
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err))
|
||||||
|
|
||||||
# check service data
|
|
||||||
(rc, out, err) = module.run_command("%s show '%s'" % (systemctl, unit))
|
|
||||||
if rc != 0:
|
|
||||||
module.fail_json(msg='failure %d running systemctl show for %r: %s' % (rc, unit, err))
|
|
||||||
|
|
||||||
found = False
|
found = False
|
||||||
is_initd = sysv_exists(unit)
|
is_initd = sysv_exists(unit)
|
||||||
is_systemd = False
|
is_systemd = False
|
||||||
|
|
||||||
|
# check service data, cannot error out on rc as it changes across versions, assume not found
|
||||||
|
(rc, out, err) = module.run_command("%s show '%s'" % (systemctl, unit))
|
||||||
|
if rc == 0:
|
||||||
# load return of systemctl show into dictionary for easy access and return
|
# load return of systemctl show into dictionary for easy access and return
|
||||||
multival = []
|
multival = []
|
||||||
if out:
|
if out:
|
||||||
|
@ -310,7 +308,6 @@ def main():
|
||||||
if is_systemd and 'LoadError' in result['status']:
|
if is_systemd and 'LoadError' in result['status']:
|
||||||
module.fail_json(msg="Error loading unit file '%s': %s" % (unit, result['status']['LoadError']))
|
module.fail_json(msg="Error loading unit file '%s': %s" % (unit, result['status']['LoadError']))
|
||||||
|
|
||||||
|
|
||||||
# Does service exist?
|
# Does service exist?
|
||||||
found = is_systemd or is_initd
|
found = is_systemd or is_initd
|
||||||
if is_initd and not is_systemd:
|
if is_initd and not is_systemd:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue