diff options
author | Dustin C. Hatch <dustin@hatch.name> | 2016-11-30 10:02:08 -0600 |
---|---|---|
committer | Brian Coca <brian.coca+git@gmail.com> | 2016-11-30 13:00:40 -0500 |
commit | d6961eb4eae1dde122ec1fd8103f85d845323acb (patch) | |
tree | 9c9e1f4114f26d3790d949f257777069ba366b87 | |
parent | b98fb5d1b3f2820e38cc739cd0c15afe5b2a9042 (diff) | |
download | ansible-modules-core-d6961eb4eae1dde122ec1fd8103f85d845323acb.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.
(cherry picked from commit 286021056f9700ab58fae92d03d9555300aef580)
-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 4f7e58dd..0a655e1d 100644 --- a/system/systemd.py +++ b/system/systemd.py @@ -377,7 +377,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: |