systemd: Start inactive units for reload/restart

The `service` module starts services that are not running when
`action=restarted` or `action=reloaded`, which is especially convenient
for initial deployments because it eliminates an extraneous operation
for when the service starts for the first time. This commit adjusts the
behavior of the `systemd` module to match.
pull/18777/head
Dustin C. Hatch 8 years ago committed by Matt Clay
parent ce0412aa85
commit b49aa70c29

@ -383,6 +383,9 @@ def main():
elif module.params['state'] == 'stopped': elif module.params['state'] == 'stopped':
if result['status']['ActiveState'] == 'active': if result['status']['ActiveState'] == 'active':
action = 'stop' action = 'stop'
else:
if result['status']['ActiveState'] != 'active':
action = 'start'
else: else:
action = module.params['state'][:-2] # remove 'ed' from restarted/reloaded action = module.params['state'][:-2] # remove 'ed' from restarted/reloaded
result['state'] = 'started' result['state'] = 'started'

Loading…
Cancel
Save