summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToshio Kuratomi <a.badger@gmail.com>2015-07-01 12:38:28 -0700
committerToshio Kuratomi <a.badger@gmail.com>2015-07-01 12:38:28 -0700
commit1458a6ec9a9433846ff20a6b9c315e57f009b020 (patch)
tree23c6c7d7f38f8d3ad4ce652045935b790a6378b5
parente3235a460f7e57a109a9fa66a0b104f767bab959 (diff)
parent361a1e1b65e65fff29a9fb8555e7559b54545e9e (diff)
downloadansible-modules-core-1458a6ec9a9433846ff20a6b9c315e57f009b020.tar.gz
Merge pull request #621 from hostmaster/supervisorctl-not-existed-sv
supervisorctl module: Check if a service exists
-rw-r--r--web_infrastructure/supervisorctl.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/web_infrastructure/supervisorctl.py b/web_infrastructure/supervisorctl.py
index 28f341d8..43fa9546 100644
--- a/web_infrastructure/supervisorctl.py
+++ b/web_infrastructure/supervisorctl.py
@@ -30,7 +30,7 @@ version_added: "0.7"
options:
name:
description:
- - The name of the supervisord program or group to manage.
+ - The name of the supervisord program or group to manage.
- The name will be taken as group name when it ends with a colon I(:)
- Group support is only available in Ansible version 1.6 or later.
required: true
@@ -194,9 +194,14 @@ def main():
if state == 'restarted':
rc, out, err = run_supervisorctl('update', check_rc=True)
processes = get_matched_processes()
+ if not processes:
+ module.fail_json(name=name, msg="ERROR (no such process)")
+
take_action_on_processes(processes, lambda s: True, 'restart', 'started')
processes = get_matched_processes()
+ if not processes:
+ module.fail_json(name=name, msg="ERROR (no such process)")
if state == 'absent':
if len(processes) == 0: