summaryrefslogtreecommitdiff
path: root/web_infrastructure
diff options
context:
space:
mode:
authorBrian Coca <bcoca@ansible.com>2015-06-30 00:38:12 -0400
committerBrian Coca <bcoca@ansible.com>2015-06-30 00:38:12 -0400
commit68a310d860a561c4cf7e84cbde7b825174ec7899 (patch)
tree2a8f4caaeaaecc88e2750aeb85399bce2f7886ef /web_infrastructure
parent79ad99bc676464a8da16b4fd2e9f9fdb18f566d6 (diff)
parent83c6cd04f48c6388a075af5d9a709667b8f007b9 (diff)
downloadansible-modules-core-68a310d860a561c4cf7e84cbde7b825174ec7899.tar.gz
Merge pull request #937 from nfubh/devel
added 'absent' option to supervisorctl
Diffstat (limited to 'web_infrastructure')
-rw-r--r--web_infrastructure/supervisorctl.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/web_infrastructure/supervisorctl.py b/web_infrastructure/supervisorctl.py
index 47d341c9..28f341d8 100644
--- a/web_infrastructure/supervisorctl.py
+++ b/web_infrastructure/supervisorctl.py
@@ -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)