rabbitmq_user: 'node' parameter: add default value (#38156)

* Remove unnecessary workaround

* add test: set RABBITMQ_NODENAME environment variable

The following error occurs:

  TASK [rabbitmq_user : Add user] ***
  fatal: [testhost]: FAILED! => {
    "changed": false,
    "cmd": "/usr/sbin/rabbitmqctl -q list_users",
    "rc": 69,
    "msg": "Error:********@c65c2bc59398'. Please see diagnostics information and suggestions below.\n\nMost common reasons for this are:\n\n * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)\n * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)\n * Target node is not running\n\nIn addition to the diagnostics info below:\n\n * See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more\n * Consult server logs on node test@c65c2bc59398\n\nDIAGNOSTICS\n===========\n\nattempted to contact:********@c65c2bc59398\n * effective user's home directory: /var/lib/rabbitmq\n * Erlang cookie hash: 3MxcYFrJzfhEL+FlUfLlQw==",
    "stderr":  [...],
    "stderr_lines": [
      "Error: unable to perform an operation on node 'test@c65c2bc59398'. Please see diagnostics information and suggestions below.", "",
      "Most common reasons for this are:", "",
      " * Target node is unreachable (e.g. due to hostname resolution, TCP connection or firewall issues)",
      " * CLI tool fails to authenticate with the server (e.g. due to CLI tool's Erlang cookie not matching that of the server)",
      " * Target node is not running", "",
      "In addition to the diagnostics info below:", "",
      " * See the CLI, clustering and networking guides on http://rabbitmq.com/documentation.html to learn more",
      " * Consult server logs on node test@c65c2bc59398", "",
          "DIAGNOSTICS", "===========", "",
          "attempted to contact: [test@c65c2bc59398]", "",
          "test@c65c2bc59398:",
      "  * connected to epmd (port 4369) on c65c2bc59398",
      "  * epmd reports: node 'test' not running at all",
      "                  other nodes on c65c2bc59398: [rabbit]",
      "  * suggestion: start the node", "",
      "Current node details:",
      " * node name: rabbitmqcli2@c65c2bc59398",
      " * effective user's home directory: /var/lib/rabbitmq",
      " * Erlang cookie hash: 3MxcYFrJzfhEL+FlUfLlQw==", ""
    ],
    "stdout": "",
    "stdout_lines": []
  }

* node parameter: fix default value

'rabbit' is the default value mentioned in the module documentation.
This commit is contained in:
Pilou 2018-10-09 00:34:08 +02:00 committed by ansibot
parent 19deb6b49e
commit 955579cd72
4 changed files with 10 additions and 13 deletions

View file

@ -143,7 +143,7 @@ class RabbitMqUser(object):
def _exec(self, args, run_in_check_mode=False):
if not self.module.check_mode or run_in_check_mode:
cmd = [self._rabbitmqctl, '-q']
if self.node is not None:
if self.node:
cmd.extend(['-n', self.node])
rc, out, err = self.module.run_command(cmd + args, check_rc=True)
return out.splitlines()
@ -245,7 +245,7 @@ def main():
read_priv=dict(default='^$'),
force=dict(default='no', type='bool'),
state=dict(default='present', choices=['present', 'absent']),
node=dict(default=None),
node=dict(default='rabbit'),
update_password=dict(default='on_create', choices=['on_create', 'always'])
)
module = AnsibleModule(

View file

@ -1,4 +1,10 @@
---
- include: tests.yml
when: ansible_distribution == 'Ubuntu'
- when: ansible_distribution == 'Ubuntu'
block:
- import_tasks: tests.yml
- import_tasks: tests.yml
environment:
RABBITMQ_NODENAME: test

View file

@ -33,11 +33,3 @@
- name: Start RabbitMQ service
service: name=rabbitmq-server state=started
when: ansible_distribution_release == 'trusty'
# This is an ugly workaround!
# There is a problem to run services via systemd inside docker containers (https://github.com/moby/moby/issues/2296):
# systemctl command fails with the error 'Failed to connect to bus: No such file or directory'
- name: Start RabbitMQ service
command: /etc/init.d/rabbitmq-server start
when: ansible_distribution_release == 'xenial'

View file

@ -581,7 +581,6 @@ lib/ansible/modules/messaging/rabbitmq_exchange.py E326
lib/ansible/modules/messaging/rabbitmq_policy.py E324
lib/ansible/modules/messaging/rabbitmq_queue.py E324
lib/ansible/modules/messaging/rabbitmq_queue.py E327
lib/ansible/modules/messaging/rabbitmq_user.py E324
lib/ansible/modules/monitoring/airbrake_deployment.py E324
lib/ansible/modules/monitoring/bigpanda.py E322
lib/ansible/modules/monitoring/bigpanda.py E324