|
|
@ -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:
|
|
|
@ -107,10 +113,11 @@ class RabbitMqUser(object):
|
|
|
|
self._tags = None
|
|
|
|
self._tags = None
|
|
|
|
self._permissions = None
|
|
|
|
self._permissions = None
|
|
|
|
self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)
|
|
|
|
self._rabbitmqctl = module.get_bin_path('rabbitmqctl', True)
|
|
|
|
|
|
|
|
self._env = module.get_bin_path('env', 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._env, 'RABBITMQ_NODENAME=%s' % self.node, self._rabbitmqctl, '-q']
|
|
|
|
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 +186,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 +203,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():
|
|
|
|