diff options
author | Brian Coca <bcoca@ansible.com> | 2015-06-30 00:38:12 -0400 |
---|---|---|
committer | Brian Coca <bcoca@ansible.com> | 2015-06-30 00:38:12 -0400 |
commit | 68a310d860a561c4cf7e84cbde7b825174ec7899 (patch) | |
tree | 2a8f4caaeaaecc88e2750aeb85399bce2f7886ef /web_infrastructure | |
parent | 79ad99bc676464a8da16b4fd2e9f9fdb18f566d6 (diff) | |
parent | 83c6cd04f48c6388a075af5d9a709667b8f007b9 (diff) | |
download | ansible-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.py | 17 |
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) |