diff options
author | Dustin C. Hatch <dustin@hatch.name> | 2016-11-30 10:02:08 -0600 |
---|---|---|
committer | Brian Coca <bcoca@users.noreply.github.com> | 2016-11-30 12:59:38 -0500 |
commit | 286021056f9700ab58fae92d03d9555300aef580 (patch) | |
tree | 9fb92db6cd18c9cfe77733431705eb37bb27fba0 | |
parent | 6890003c4f8dcd8f63a5b280211068cfaf1dcc35 (diff) | |
download | ansible-modules-core-286021056f9700ab58fae92d03d9555300aef580.tar.gz |
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.
-rw-r--r-- | system/systemd.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/system/systemd.py b/system/systemd.py index 19fedce4..dcc493b8 100644 --- a/system/systemd.py +++ b/system/systemd.py @@ -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: |