summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDustin C. Hatch <dustin@hatch.name>2016-11-30 10:02:08 -0600
committerBrian Coca <bcoca@users.noreply.github.com>2016-11-30 12:59:38 -0500
commit286021056f9700ab58fae92d03d9555300aef580 (patch)
tree9fb92db6cd18c9cfe77733431705eb37bb27fba0
parent6890003c4f8dcd8f63a5b280211068cfaf1dcc35 (diff)
downloadansible-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.py5
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: