Merge pull request #621 from hostmaster/supervisorctl-not-existed-sv
supervisorctl module: Check if a service exists
This commit is contained in:
commit
1458a6ec9a
1 changed files with 6 additions and 1 deletions
|
@ -30,7 +30,7 @@ version_added: "0.7"
|
||||||
options:
|
options:
|
||||||
name:
|
name:
|
||||||
description:
|
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(:)
|
- 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.
|
- Group support is only available in Ansible version 1.6 or later.
|
||||||
required: true
|
required: true
|
||||||
|
@ -194,9 +194,14 @@ def main():
|
||||||
if state == 'restarted':
|
if state == 'restarted':
|
||||||
rc, out, err = run_supervisorctl('update', check_rc=True)
|
rc, out, err = run_supervisorctl('update', check_rc=True)
|
||||||
processes = get_matched_processes()
|
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')
|
take_action_on_processes(processes, lambda s: True, 'restart', 'started')
|
||||||
|
|
||||||
processes = get_matched_processes()
|
processes = get_matched_processes()
|
||||||
|
if not processes:
|
||||||
|
module.fail_json(name=name, msg="ERROR (no such process)")
|
||||||
|
|
||||||
if state == 'absent':
|
if state == 'absent':
|
||||||
if len(processes) == 0:
|
if len(processes) == 0:
|
||||||
|
|
Loading…
Reference in a new issue