1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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.
This commit is contained in:
Dustin C. Hatch 2016-11-30 10:02:08 -06:00 committed by Matt Clay
parent ce0412aa85
commit b49aa70c29

View file

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