From 3177e9eaf0144a97f5beb61a4edd4cb63f2f62eb Mon Sep 17 00:00:00 2001 From: Brad Wilson Date: Wed, 11 Nov 2015 14:42:11 -0800 Subject: [PATCH] Add apply_to option to rabbitmq_policy --- messaging/rabbitmq_policy.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/messaging/rabbitmq_policy.py b/messaging/rabbitmq_policy.py index 81d7068ec46..0a7d023dfb6 100644 --- a/messaging/rabbitmq_policy.py +++ b/messaging/rabbitmq_policy.py @@ -38,6 +38,12 @@ options: - The name of the vhost to apply to. required: false 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: description: - A regex of queues to apply the policy to. @@ -81,6 +87,7 @@ class RabbitMqPolicy(object): self._name = name self._vhost = module.params['vhost'] self._pattern = module.params['pattern'] + self._apply_to = module.params['apply_to'] self._tags = module.params['tags'] self._priority = module.params['priority'] self._node = module.params['node'] @@ -112,6 +119,9 @@ class RabbitMqPolicy(object): args.append(json.dumps(self._tags)) args.append('--priority') args.append(self._priority) + if (self._apply_to != 'all'): + args.append('--apply-to') + args.append(self._apply_to) return self._exec(args) def clear(self): @@ -123,6 +133,7 @@ def main(): name=dict(required=True), vhost=dict(default='/'), pattern=dict(required=True), + apply_to=dict(default='all', choices=['all', 'exchanges', 'queues']), tags=dict(type='dict', required=True), priority=dict(default='0'), node=dict(default='rabbit'),