Merge pull request #1780 from hostmaster/supervisorctl-present-state-fix
Bugfix Pull Request: supervisorctl module: 'present' state is broken
This commit is contained in:
commit
bdb5aa8f88
1 changed files with 7 additions and 5 deletions
|
@ -75,8 +75,8 @@ notes:
|
||||||
- When C(state) = I(present), the module will call C(supervisorctl reread) then C(supervisorctl add) if the program/group does not exist.
|
- When C(state) = I(present), the module will call C(supervisorctl reread) then C(supervisorctl add) if the program/group does not exist.
|
||||||
- When C(state) = I(restarted), the module will call C(supervisorctl update) then call C(supervisorctl restart).
|
- When C(state) = I(restarted), the module will call C(supervisorctl update) then call C(supervisorctl restart).
|
||||||
requirements: [ "supervisorctl" ]
|
requirements: [ "supervisorctl" ]
|
||||||
author:
|
author:
|
||||||
- "Matt Wright (@mattupstate)"
|
- "Matt Wright (@mattupstate)"
|
||||||
- "Aaron Wang (@inetfuture) <inetfuture@gmail.com>"
|
- "Aaron Wang (@inetfuture) <inetfuture@gmail.com>"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
@ -194,14 +194,12 @@ 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:
|
if len(processes) == 0:
|
||||||
module.fail_json(name=name, msg="ERROR (no such process)")
|
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:
|
||||||
|
@ -230,9 +228,13 @@ def main():
|
||||||
module.fail_json(msg=out, name=name, state=state)
|
module.fail_json(msg=out, name=name, state=state)
|
||||||
|
|
||||||
if state == 'started':
|
if state == 'started':
|
||||||
|
if len(processes) == 0:
|
||||||
|
module.fail_json(name=name, msg="ERROR (no such process)")
|
||||||
take_action_on_processes(processes, lambda s: s not in ('RUNNING', 'STARTING'), 'start', 'started')
|
take_action_on_processes(processes, lambda s: s not in ('RUNNING', 'STARTING'), 'start', 'started')
|
||||||
|
|
||||||
if state == 'stopped':
|
if state == 'stopped':
|
||||||
|
if len(processes) == 0:
|
||||||
|
module.fail_json(name=name, msg="ERROR (no such process)")
|
||||||
take_action_on_processes(processes, lambda s: s in ('RUNNING', 'STARTING'), 'stop', 'stopped')
|
take_action_on_processes(processes, lambda s: s in ('RUNNING', 'STARTING'), 'stop', 'stopped')
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
Loading…
Reference in a new issue