Add apply_to option to rabbitmq_policy

reviewable/pr18780/r1
Brad Wilson 9 years ago
parent 1de3509f3b
commit 3177e9eaf0

@ -38,6 +38,12 @@ options:
- The name of the vhost to apply to. - The name of the vhost to apply to.
required: false required: false
default: / default: /
apply_to:
description:
- What the policy applies to. Requires RabbitMQ 3.2.0 or later.
required: false
default: all
choices: [all, exchanges, queues]
pattern: pattern:
description: description:
- A regex of queues to apply the policy to. - A regex of queues to apply the policy to.
@ -81,6 +87,7 @@ class RabbitMqPolicy(object):
self._name = name self._name = name
self._vhost = module.params['vhost'] self._vhost = module.params['vhost']
self._pattern = module.params['pattern'] self._pattern = module.params['pattern']
self._apply_to = module.params['apply_to']
self._tags = module.params['tags'] self._tags = module.params['tags']
self._priority = module.params['priority'] self._priority = module.params['priority']
self._node = module.params['node'] self._node = module.params['node']
@ -112,6 +119,9 @@ class RabbitMqPolicy(object):
args.append(json.dumps(self._tags)) args.append(json.dumps(self._tags))
args.append('--priority') args.append('--priority')
args.append(self._priority) args.append(self._priority)
if (self._apply_to != 'all'):
args.append('--apply-to')
args.append(self._apply_to)
return self._exec(args) return self._exec(args)
def clear(self): def clear(self):
@ -123,6 +133,7 @@ def main():
name=dict(required=True), name=dict(required=True),
vhost=dict(default='/'), vhost=dict(default='/'),
pattern=dict(required=True), pattern=dict(required=True),
apply_to=dict(default='all', choices=['all', 'exchanges', 'queues']),
tags=dict(type='dict', required=True), tags=dict(type='dict', required=True),
priority=dict(default='0'), priority=dict(default='0'),
node=dict(default='rabbit'), node=dict(default='rabbit'),

Loading…
Cancel
Save