Merge pull request #937 from nfubh/devel
added 'absent' option to supervisorctl
This commit is contained in:
commit
68a310d860
1 changed files with 15 additions and 2 deletions
|
@ -64,7 +64,7 @@ options:
|
|||
- The desired state of program/group.
|
||||
required: true
|
||||
default: null
|
||||
choices: [ "present", "started", "stopped", "restarted" ]
|
||||
choices: [ "present", "started", "stopped", "restarted", "absent" ]
|
||||
supervisorctl_path:
|
||||
description:
|
||||
- path to supervisorctl executable
|
||||
|
@ -103,7 +103,7 @@ def main():
|
|||
username=dict(required=False),
|
||||
password=dict(required=False),
|
||||
supervisorctl_path=dict(required=False),
|
||||
state=dict(required=True, choices=['present', 'started', 'restarted', 'stopped'])
|
||||
state=dict(required=True, choices=['present', 'started', 'restarted', 'stopped', 'absent'])
|
||||
)
|
||||
|
||||
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||
|
@ -198,6 +198,19 @@ def main():
|
|||
|
||||
processes = get_matched_processes()
|
||||
|
||||
if state == 'absent':
|
||||
if len(processes) == 0:
|
||||
module.exit_json(changed=False, name=name, state=state)
|
||||
|
||||
if module.check_mode:
|
||||
module.exit_json(changed=True)
|
||||
run_supervisorctl('reread', check_rc=True)
|
||||
rc, out, err = run_supervisorctl('remove', name)
|
||||
if '%s: removed process group' % name in out:
|
||||
module.exit_json(changed=True, name=name, state=state)
|
||||
else:
|
||||
module.fail_json(msg=out, name=name, state=state)
|
||||
|
||||
if state == 'present':
|
||||
if len(processes) > 0:
|
||||
module.exit_json(changed=False, name=name, state=state)
|
||||
|
|
Loading…
Reference in a new issue