mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2867 from cstorey/rabbitmq_user-node-parameter
Allow specification of erlang node name for rabbitmq_user/vhost/parameter actions.
This commit is contained in:
commit
ebf28ff856
3 changed files with 36 additions and 12 deletions
|
@ -47,6 +47,11 @@ options:
|
||||||
- vhost to apply access privileges.
|
- vhost to apply access privileges.
|
||||||
required: false
|
required: false
|
||||||
default: /
|
default: /
|
||||||
|
node:
|
||||||
|
description:
|
||||||
|
- erlang node name of the rabbit we wish to configure
|
||||||
|
required: false
|
||||||
|
default: rabbit
|
||||||
state:
|
state:
|
||||||
description:
|
description:
|
||||||
- Specify if user is to be added or removed
|
- Specify if user is to be added or removed
|
||||||
|
@ -61,12 +66,13 @@ rabbitmq_parameter: component=federation name=local-username value='"guest"' sta
|
||||||
"""
|
"""
|
||||||
|
|
||||||
class RabbitMqParameter(object):
|
class RabbitMqParameter(object):
|
||||||
def __init__(self, module, component, name, value, vhost):
|
def __init__(self, module, component, name, value, vhost, node):
|
||||||
self.module = module
|
self.module = module
|
||||||
self.component = component
|
self.component = component
|
||||||
self.name = name
|
self.name = name
|
||||||
self.value = value
|
self.value = value
|
||||||
self.vhost = vhost
|
self.vhost = vhost
|
||||||
|
self.node = node
|
||||||
|
|
||||||
self._value = None
|
self._value = None
|
||||||
|
|
||||||
|
@ -74,7 +80,7 @@ class RabbitMqParameter(object):
|
||||||
|
|
||||||
def _exec(self, args, run_in_check_mode=False):
|
def _exec(self, args, run_in_check_mode=False):
|
||||||
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
||||||
cmd = [self._rabbitmqctl, '-q']
|
cmd = [self._rabbitmqctl, '-q', '-n', self.node]
|
||||||
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
||||||
return out.splitlines()
|
return out.splitlines()
|
||||||
return list()
|
return list()
|
||||||
|
@ -105,7 +111,8 @@ def main():
|
||||||
name=dict(required=True),
|
name=dict(required=True),
|
||||||
value=dict(default=None),
|
value=dict(default=None),
|
||||||
vhost=dict(default='/'),
|
vhost=dict(default='/'),
|
||||||
state=dict(default='present', choices=['present', 'absent'])
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
node=dict(default='rabbit')
|
||||||
)
|
)
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=arg_spec,
|
argument_spec=arg_spec,
|
||||||
|
@ -117,8 +124,9 @@ def main():
|
||||||
value = module.params['value']
|
value = module.params['value']
|
||||||
vhost = module.params['vhost']
|
vhost = module.params['vhost']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
node = module.params['node']
|
||||||
|
|
||||||
rabbitmq_parameter = RabbitMqParameter(module, component, name, value, vhost)
|
rabbitmq_parameter = RabbitMqParameter(module, component, name, value, vhost, node)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if rabbitmq_parameter.get():
|
if rabbitmq_parameter.get():
|
||||||
|
|
|
@ -48,6 +48,11 @@ options:
|
||||||
- vhost to apply access privileges.
|
- vhost to apply access privileges.
|
||||||
required: false
|
required: false
|
||||||
default: /
|
default: /
|
||||||
|
node:
|
||||||
|
description:
|
||||||
|
- erlang node name of the rabbit we wish to configure
|
||||||
|
required: false
|
||||||
|
default: rabbit
|
||||||
configure_priv:
|
configure_priv:
|
||||||
description:
|
description:
|
||||||
- Regular expression to restrict configure actions on a resource
|
- Regular expression to restrict configure actions on a resource
|
||||||
|
@ -87,10 +92,11 @@ examples:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class RabbitMqUser(object):
|
class RabbitMqUser(object):
|
||||||
def __init__(self, module, username, password, tags, vhost, configure_priv, write_priv, read_priv):
|
def __init__(self, module, username, password, tags, vhost, configure_priv, write_priv, read_priv, node):
|
||||||
self.module = module
|
self.module = module
|
||||||
self.username = username
|
self.username = username
|
||||||
self.password = password
|
self.password = password
|
||||||
|
self.node = node
|
||||||
if tags is None:
|
if tags is None:
|
||||||
self.tags = list()
|
self.tags = list()
|
||||||
else:
|
else:
|
||||||
|
@ -110,7 +116,7 @@ class RabbitMqUser(object):
|
||||||
|
|
||||||
def _exec(self, args, run_in_check_mode=False):
|
def _exec(self, args, run_in_check_mode=False):
|
||||||
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
||||||
cmd = [self._rabbitmqctl, '-q']
|
cmd = [self._rabbitmqctl, '-q', '-n', self.node]
|
||||||
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
||||||
return out.splitlines()
|
return out.splitlines()
|
||||||
return list()
|
return list()
|
||||||
|
@ -179,7 +185,8 @@ def main():
|
||||||
write_priv=dict(default='^$'),
|
write_priv=dict(default='^$'),
|
||||||
read_priv=dict(default='^$'),
|
read_priv=dict(default='^$'),
|
||||||
force=dict(default='no', type='bool'),
|
force=dict(default='no', type='bool'),
|
||||||
state=dict(default='present', choices=['present', 'absent'])
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
node=dict(default='rabbit')
|
||||||
)
|
)
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
argument_spec=arg_spec,
|
argument_spec=arg_spec,
|
||||||
|
@ -195,8 +202,9 @@ def main():
|
||||||
read_priv = module.params['read_priv']
|
read_priv = module.params['read_priv']
|
||||||
force = module.params['force']
|
force = module.params['force']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
node = module.params['node']
|
||||||
|
|
||||||
rabbitmq_user = RabbitMqUser(module, username, password, tags, vhost, configure_priv, write_priv, read_priv)
|
rabbitmq_user = RabbitMqUser(module, username, password, tags, vhost, configure_priv, write_priv, read_priv, node)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if rabbitmq_user.get():
|
if rabbitmq_user.get():
|
||||||
|
|
|
@ -34,6 +34,11 @@ options:
|
||||||
required: true
|
required: true
|
||||||
default: null
|
default: null
|
||||||
aliases: [vhost]
|
aliases: [vhost]
|
||||||
|
node:
|
||||||
|
description:
|
||||||
|
- erlang node name of the rabbit we wish to configure
|
||||||
|
required: false
|
||||||
|
default: rabbit
|
||||||
tracing:
|
tracing:
|
||||||
description:
|
description:
|
||||||
- Enable/disable tracing for a vhost
|
- Enable/disable tracing for a vhost
|
||||||
|
@ -51,17 +56,18 @@ examples:
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class RabbitMqVhost(object):
|
class RabbitMqVhost(object):
|
||||||
def __init__(self, module, name, tracing):
|
def __init__(self, module, name, tracing, node):
|
||||||
self.module = module
|
self.module = module
|
||||||
self.name = name
|
self.name = name
|
||||||
self.tracing = tracing
|
self.tracing = tracing
|
||||||
|
self.node = node
|
||||||
|
|
||||||
self._tracing = False
|
self._tracing = False
|
||||||
self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)
|
self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)
|
||||||
|
|
||||||
def _exec(self, args, run_in_check_mode=False):
|
def _exec(self, args, run_in_check_mode=False):
|
||||||
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
if not self.module.check_mode or (self.module.check_mode and run_in_check_mode):
|
||||||
cmd = [self._rabbitmqctl, '-q']
|
cmd = [self._rabbitmqctl, '-q', '-n', self.node]
|
||||||
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
|
||||||
return out.splitlines()
|
return out.splitlines()
|
||||||
return list()
|
return list()
|
||||||
|
@ -102,7 +108,8 @@ def main():
|
||||||
arg_spec = dict(
|
arg_spec = dict(
|
||||||
name=dict(required=True, aliases=['vhost']),
|
name=dict(required=True, aliases=['vhost']),
|
||||||
tracing=dict(default='off', aliases=['trace'], type='bool'),
|
tracing=dict(default='off', aliases=['trace'], type='bool'),
|
||||||
state=dict(default='present', choices=['present', 'absent'])
|
state=dict(default='present', choices=['present', 'absent']),
|
||||||
|
node=dict(default='rabbit'),
|
||||||
)
|
)
|
||||||
|
|
||||||
module = AnsibleModule(
|
module = AnsibleModule(
|
||||||
|
@ -113,8 +120,9 @@ def main():
|
||||||
name = module.params['name']
|
name = module.params['name']
|
||||||
tracing = module.params['tracing']
|
tracing = module.params['tracing']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
node = module.params['node']
|
||||||
|
|
||||||
rabbitmq_vhost = RabbitMqVhost(module, name, tracing)
|
rabbitmq_vhost = RabbitMqVhost(module, name, tracing, node)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
if rabbitmq_vhost.get():
|
if rabbitmq_vhost.get():
|
||||||
|
|
Loading…
Reference in a new issue