make daemon reload first thing always run
otherwise service detection can fail before we run it which might be required to actually detect the service.
This commit is contained in:
parent
f874c29dff
commit
186db40864
1 changed files with 6 additions and 7 deletions
|
@ -241,6 +241,12 @@ def main():
|
||||||
'status': {},
|
'status': {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Run daemon-reload first, if requested
|
||||||
|
if module.params['daemon_reload']:
|
||||||
|
(rc, out, err) = module.run_command("%s daemon-reload" % (systemctl))
|
||||||
|
if rc != 0:
|
||||||
|
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err))
|
||||||
|
|
||||||
#TODO: check if service exists
|
#TODO: check if service exists
|
||||||
(rc, out, err) = module.run_command("%s show '%s'" % (systemctl, unit))
|
(rc, out, err) = module.run_command("%s show '%s'" % (systemctl, unit))
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
@ -269,18 +275,11 @@ def main():
|
||||||
multival.append(line)
|
multival.append(line)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if 'LoadState' in result['status'] and result['status']['LoadState'] == 'not-found':
|
if 'LoadState' in result['status'] and result['status']['LoadState'] == 'not-found':
|
||||||
module.fail_json(msg='Could not find the requested service "%r": %s' % (unit, err))
|
module.fail_json(msg='Could not find the requested service "%r": %s' % (unit, err))
|
||||||
elif 'LoadError' in result['status']:
|
elif 'LoadError' in result['status']:
|
||||||
module.fail_json(msg="Failed to get the service status '%s': %s" % (unit, result['status']['LoadError']))
|
module.fail_json(msg="Failed to get the service status '%s': %s" % (unit, result['status']['LoadError']))
|
||||||
|
|
||||||
# Run daemon-reload first, if requested
|
|
||||||
if module.params['daemon_reload']:
|
|
||||||
(rc, out, err) = module.run_command("%s daemon-reload" % (systemctl))
|
|
||||||
if rc != 0:
|
|
||||||
module.fail_json(msg='failure %d during daemon-reload: %s' % (rc, err))
|
|
||||||
|
|
||||||
# mask/unmask the service, if requested
|
# mask/unmask the service, if requested
|
||||||
if module.params['masked'] is not None:
|
if module.params['masked'] is not None:
|
||||||
masked = (result['status']['LoadState'] == 'masked')
|
masked = (result['status']['LoadState'] == 'masked')
|
||||||
|
|
Loading…
Reference in a new issue