community.rabbitmq icon indicating copy to clipboard operation
community.rabbitmq copied to clipboard

Ansible community.rabbitmq can't use RABBITMQ_USE_LONGNAME

Open kost1993 opened this issue 3 years ago • 1 comments

SUMMARY

There is a problem with cluster which uses longnames in rabbitmq cluster. For now there is no possible way to use any play against such clusters. There is no such option in plugins and possible life hacks such as setting remote environment doesn’t work. For instance: rabbitmqctl can be used in bash with longnames:

sudo RABBITMQ_USE_LONGNAME=true [email protected] rabbitmqctl ...
or
sudo rabbitmqctl --longnames [email protected] ...

But in the rabbitmq_user.py of ansible collection there is no possible way to use such option for longnames. In definition _exec https://github.com/ansible-collections/community.rabbitmq/blob/65b0022243af0780a91480f18f019eada432eb86/plugins/modules/rabbitmq_user.py#L285 it can use flag --node but not --longnames.

ISSUE TYPE
  • Bug Report
COMPONENT NAME
rabbitmq_user
rabbitmq_vhost
ANSIBLE VERSION
ansible --version

ansible [core 2.11.6]
  config file = /home/k_ilyasov/ansible.cfg
  configured module search path = ['/home/k_ilyasov/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.9/dist-packages/ansible
  ansible collection location = /home/k_ilyasov/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.9.2 (default, Feb 28 2021, 17:03:44) [GCC 10.2.1 20210110]
  jinja version = 3.0.2
  libyaml = True
COLLECTION VERSION
ansible-galaxy collection list community.rabbitmq

# /usr/local/lib/python3.9/dist-packages/ansible_collections
Collection         Version
------------------ -------
community.rabbitmq 1.1.0
CONFIGURATION
Default configuration
OS / ENVIRONMENT

OS: Debian 11

STEPS TO REPRODUCE
- block:
  - name: "delete default user guest"
    community.rabbitmq.rabbitmq_user:
      user: guest
      state: absent
    environment:
      RABBITMQ_USE_LONGNAME: "true"
      RABBITMQ_NODENAME: "{{ rabbitmq_node_name }}"
    vars:
      rabbitmq_node_name: "[email protected]"
EXPECTED RESULTS

Users should be created or deleted.

ACTUAL RESULTS

Playbook failed.

TASK [rabbitmq-server : delete default user guest] *********************************************************************
fatal: [testrmq01]: FAILED! => {"changed": false, "msg": "Could not determine the version of the RabbitMQ server."}

kost1993 avatar Jan 29 '22 15:01 kost1993

For me it works as of today:

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 12 (bookworm)
Release:	12
Codename:	bookworm
$ ansible --version
ansible [core 2.14.3]

(from debian repos)

$ ansible-galaxy collection list community.rabbitmq
Collection         Version
------------------ -------
community.rabbitmq 1.3.0 

(not from debian repos, from galaxy, because of login_user)

The only trick that's left, is that you have to set the node explicitely:

    rabbitmq_user:
        node: "rabbit@{{ rabbitmq_nodename }}"

whereby rabbitmq_nodename is some fqdn.

And I specified RABBITMQ_USE_LONGNAME=yes in /etc/rabbitmq/rabbitmq-env.conf

So maybe you want to close this issue?

manuelschneider avatar Jun 15 '24 09:06 manuelschneider