From 2a6d1c278588f0577157bb93fff449064cf7fa0a Mon Sep 17 00:00:00 2001 From: rockandska Date: Thu, 28 Oct 2021 00:37:11 +0200 Subject: [PATCH 1/3] fix(rabbitmq_plugin): add node to module args --- plugins/modules/rabbitmq_plugin.py | 8 ++++++++ .../targets/rabbitmq_plugin/tasks/tests.yml | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/plugins/modules/rabbitmq_plugin.py b/plugins/modules/rabbitmq_plugin.py index c6fe8d7..c56add5 100644 --- a/plugins/modules/rabbitmq_plugin.py +++ b/plugins/modules/rabbitmq_plugin.py @@ -29,6 +29,11 @@ - Does not disable plugins that are not in the names list. type: bool default: "no" + node: + description: + - erlang node name of the rabbit we wish to configure + type: str + default: rabbit state: description: - Specify if plugins are to be enabled or disabled. @@ -114,6 +119,8 @@ def __init__(self, module): def _exec(self, args, force_exec_in_check_mode=False): if not self.module.check_mode or (self.module.check_mode and force_exec_in_check_mode): cmd = [self._rabbitmq_plugins] + if self.module.params['node']: + cmd.extend(['-n', self.module.params['node']]) rc, out, err = self.module.run_command(cmd + args, check_rc=True) return out.splitlines() return list() @@ -139,6 +146,7 @@ def main(): arg_spec = dict( names=dict(required=True, aliases=['name']), new_only=dict(default='no', type='bool'), + node=dict(default='rabbit'), state=dict(default='enabled', choices=['enabled', 'disabled']), broker_state=dict(default='online', choices=['online', 'offline']), prefix=dict(required=False, default=None) diff --git a/tests/integration/targets/rabbitmq_plugin/tasks/tests.yml b/tests/integration/targets/rabbitmq_plugin/tasks/tests.yml index 148f191..4a0974c 100644 --- a/tests/integration/targets/rabbitmq_plugin/tasks/tests.yml +++ b/tests/integration/targets/rabbitmq_plugin/tasks/tests.yml @@ -130,6 +130,20 @@ that: - result is not changed + - name: Using custom node should fail [online] + rabbitmq_plugin: + name: "{{ plugin_name }}" + state: enabled + new_only: True + node: bunny + register: result + ignore_errors: yes + + - assert: + that: + - "result is failed" + - "result.cmd == '/usr/sbin/rabbitmq-plugins -n bunny enable --online rabbitmq_top'" + always: - name: Disable plugin rabbitmq_plugin: From 2ca751145ab961628f0c7b148ac4c781a41a1da3 Mon Sep 17 00:00:00 2001 From: rockandska Date: Tue, 2 Nov 2021 09:04:19 +0100 Subject: [PATCH 2/3] chore(changelog): add fragment --- changelogs/fragments/106-use-node-with-plugin.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/106-use-node-with-plugin.yml diff --git a/changelogs/fragments/106-use-node-with-plugin.yml b/changelogs/fragments/106-use-node-with-plugin.yml new file mode 100644 index 0000000..74e724c --- /dev/null +++ b/changelogs/fragments/106-use-node-with-plugin.yml @@ -0,0 +1,2 @@ +minor_changes: + - rabbitmq_plugin - add node arguments. From e129073c9682001da955e281829d4eaf25aaae3b Mon Sep 17 00:00:00 2001 From: rockandska Date: Tue, 2 Nov 2021 09:09:09 +0100 Subject: [PATCH 3/3] chore(rabbitmq_plugin): add example for node arg --- plugins/modules/rabbitmq_plugin.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plugins/modules/rabbitmq_plugin.py b/plugins/modules/rabbitmq_plugin.py index c56add5..bb46986 100644 --- a/plugins/modules/rabbitmq_plugin.py +++ b/plugins/modules/rabbitmq_plugin.py @@ -31,7 +31,7 @@ default: "no" node: description: - - erlang node name of the rabbit we wish to configure + - Erlang node name of the rabbit we wish to configure. type: str default: rabbit state: @@ -79,6 +79,12 @@ names: rabbitmq_peer_discovery_aws_plugin state: enabled broker_state: offline + +- name: Enables plugin with custom node name + community.rabbitmq.rabbitmq_plugin: + names: rabbitmq_management + state: enabled + node: bunny ''' RETURN = r'''