mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
added 'absent' option to supervisorctl
This commit is contained in:
parent
4ee972190b
commit
8bd367eac7
1 changed files with 15 additions and 2 deletions
|
@ -64,7 +64,7 @@ options:
|
||||||
- The desired state of program/group.
|
- The desired state of program/group.
|
||||||
required: true
|
required: true
|
||||||
default: null
|
default: null
|
||||||
choices: [ "present", "started", "stopped", "restarted" ]
|
choices: [ "present", "started", "stopped", "restarted", "absent" ]
|
||||||
supervisorctl_path:
|
supervisorctl_path:
|
||||||
description:
|
description:
|
||||||
- path to supervisorctl executable
|
- path to supervisorctl executable
|
||||||
|
@ -103,7 +103,7 @@ def main():
|
||||||
username=dict(required=False),
|
username=dict(required=False),
|
||||||
password=dict(required=False),
|
password=dict(required=False),
|
||||||
supervisorctl_path=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)
|
module = AnsibleModule(argument_spec=arg_spec, supports_check_mode=True)
|
||||||
|
@ -203,6 +203,19 @@ def main():
|
||||||
if not processes:
|
if not processes:
|
||||||
module.fail_json(name=name, msg="ERROR (no such process)")
|
module.fail_json(name=name, msg="ERROR (no such process)")
|
||||||
|
|
||||||
|
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 state == 'present':
|
||||||
if len(processes) > 0:
|
if len(processes) > 0:
|
||||||
module.exit_json(changed=False, name=name, state=state)
|
module.exit_json(changed=False, name=name, state=state)
|
||||||
|
|
Loading…
Reference in a new issue