From 8a6df38cc5c14c569ac02260fd140549ff79dd68 Mon Sep 17 00:00:00 2001 From: Fabio Alessandro Locati Date: Thu, 1 Dec 2016 13:59:53 +0000 Subject: [PATCH] Native YAML - messaging (#3599) --- .../extras/messaging/rabbitmq_binding.py | 12 ++++++-- .../extras/messaging/rabbitmq_exchange.py | 8 ++++-- .../extras/messaging/rabbitmq_parameter.py | 9 +++--- .../extras/messaging/rabbitmq_plugin.py | 4 ++- .../extras/messaging/rabbitmq_policy.py | 12 ++++++-- .../extras/messaging/rabbitmq_queue.py | 9 ++++-- .../modules/extras/messaging/rabbitmq_user.py | 28 +++++++++++-------- .../extras/messaging/rabbitmq_vhost.py | 4 ++- 8 files changed, 60 insertions(+), 26 deletions(-) diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_binding.py b/lib/ansible/modules/extras/messaging/rabbitmq_binding.py index c1ca32a1ce4..bc466388acc 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_binding.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_binding.py @@ -94,10 +94,18 @@ options: EXAMPLES = ''' # Bind myQueue to directExchange with routing key info -- rabbitmq_binding: name=directExchange destination=myQueue type=queue routing_key=info +- rabbitmq_binding: + name: directExchange + destination: myQueue + type: queue + routing_key: info # Bind directExchange to topicExchange with routing key *.info -- rabbitmq_binding: name=topicExchange destination=topicExchange type=exchange routing_key="*.info" +- rabbitmq_binding: + name: topicExchange + destination: topicExchange + type: exchange + routing_key: *.info ''' import requests diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py b/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py index d69a536bfee..74758457270 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_exchange.py @@ -80,10 +80,14 @@ options: EXAMPLES = ''' # Create direct exchange -- rabbitmq_exchange: name=directExchange +- rabbitmq_exchange: + name: directExchange # Create topic exchange on vhost -- rabbitmq_exchange: name=topicExchange type=topic vhost=myVhost +- rabbitmq_exchange: + name: topicExchange + type: topic + vhost: myVhost ''' import requests diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_parameter.py b/lib/ansible/modules/extras/messaging/rabbitmq_parameter.py index 9022910928b..602f92fc4c4 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_parameter.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_parameter.py @@ -63,10 +63,11 @@ options: EXAMPLES = """ # Set the federation parameter 'local_username' to a value of 'guest' (in quotes) -- rabbitmq_parameter: component=federation - name=local-username - value='"guest"' - state=present +- rabbitmq_parameter: + component: federation + name: local-username + value: '"guest"' + state: present """ class RabbitMqParameter(object): diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_plugin.py b/lib/ansible/modules/extras/messaging/rabbitmq_plugin.py index b52de337e2e..6aa4fac3053 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_plugin.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_plugin.py @@ -56,7 +56,9 @@ options: EXAMPLES = ''' # Enables the rabbitmq_management plugin -- rabbitmq_plugin: names=rabbitmq_management state=enabled +- rabbitmq_plugin: + names: rabbitmq_management + state: enabled ''' import os diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_policy.py b/lib/ansible/modules/extras/messaging/rabbitmq_policy.py index a9207b3cbcd..8293f6f8972 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_policy.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_policy.py @@ -74,13 +74,19 @@ options: EXAMPLES = ''' - name: ensure the default vhost contains the HA policy via a dict - rabbitmq_policy: name=HA pattern='.*' + rabbitmq_policy: + name: HA + pattern: .* args: tags: - "ha-mode": all + ha-mode: all - name: ensure the default vhost contains the HA policy - rabbitmq_policy: name=HA pattern='.*' tags="ha-mode=all" + rabbitmq_policy: + name: HA + pattern: .* + tags: + - ha-mode: all ''' class RabbitMqPolicy(object): def __init__(self, module, name): diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_queue.py b/lib/ansible/modules/extras/messaging/rabbitmq_queue.py index c7c8b80250c..ec9e782f40d 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_queue.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_queue.py @@ -94,10 +94,15 @@ options: EXAMPLES = ''' # Create a queue -- rabbitmq_queue: name=myQueue +- rabbitmq_queue: + name: myQueue # Create a queue on remote host -- rabbitmq_queue: name=myRemoteQueue login_user=user login_password=secret login_host=remote.example.org +- rabbitmq_queue: + name: myRemoteQueue + login_user: user + login_password: secret + login_host: remote.example.org ''' import requests diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_user.py b/lib/ansible/modules/extras/messaging/rabbitmq_user.py index 103650e2c94..470ae7c1431 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_user.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_user.py @@ -107,20 +107,26 @@ options: EXAMPLES = ''' # Add user to server and assign full access control on / vhost. # The user might have permission rules for other vhost but you don't care. -- rabbitmq_user: user=joe - password=changeme - vhost=/ - configure_priv=.* - read_priv=.* - write_priv=.* - state=present +- rabbitmq_user: + user: joe + password: changeme + vhost: / + configure_priv: .* + read_priv: .* + write_priv: .* + state: present # Add user to server and assign full access control on / vhost. # The user doesn't have permission rules for other vhosts -- rabbitmq_user: user=joe - password=changeme - permissions=[{vhost='/', configure_priv='.*', read_priv='.*', write_priv='.*'}] - state=present +- rabbitmq_user: + user: joe + password: changeme + permissions: + - vhost: / + configure_priv: .* + read_priv: .* + write_priv: .* + state: present ''' class RabbitMqUser(object): diff --git a/lib/ansible/modules/extras/messaging/rabbitmq_vhost.py b/lib/ansible/modules/extras/messaging/rabbitmq_vhost.py index dbde32393cb..1ffb3d2674f 100644 --- a/lib/ansible/modules/extras/messaging/rabbitmq_vhost.py +++ b/lib/ansible/modules/extras/messaging/rabbitmq_vhost.py @@ -55,7 +55,9 @@ options: EXAMPLES = ''' # Ensure that the vhost /test exists. -- rabbitmq_vhost: name=/test state=present +- rabbitmq_vhost: + name: /test + state: present ''' class RabbitMqVhost(object):