0

I am trying to set up a rabbitMQ user using ansible's user management module.

Here is the code:

- rabbitmq_user:
    user: "{{ rabbitmq_username }}"
    password: "{{ rabbitmq_username }}"
    vhost: /
    configure_priv: .*
    read_priv: .*
    write_priv: .*
    state: present
  notify: restart rabbitmq

My application fails to authenticate using the above credentials to RabbitMQ. Also, the /etc/rabbitmq folder, which houses user configuration is empty.

Here is my complete task file which also installs rabbitMQ.

---

- include_role:
    name: geerlingguy.rabbitmq
  vars:
    rabbitmq_version: "3.7.9"

    rabbitmq_daemon: rabbitmq-server

    rabbitmq_state: started

    rabbitmq_enabled: true

- rabbitmq_user:
    user: "{{ rabbitmq_username }}"
    password: "{{ rabbitmq_username }}"
    vhost: /
    configure_priv: .*
    read_priv: .*
    write_priv: .*
    state: present
  notify: restart rabbitmq

- name: Enable RabbitMQ management console
  command: rabbitmq-plugins enable rabbitmq_management

I can see that RabbitMQ is installed successfully and it starts but the user isn't created. I can't even authenticate to the Web UI using the above credentials. Why is this happening and how to resolve this issue?

EDIT (Ansible Output):

TASK [geerlingguy.rabbitmq : Ensure erlang is installed.] *********************************************************************************************************************************************************ok: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Add packagecloud GPG key.] ***********************************************************************************************************************************************************skipping: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Download RabbitMQ package.] **********************************************************************************************************************************************************skipping: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Ensure RabbitMQ is installed.] *******************************************************************************************************************************************************skipping: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Download RabbitMQ package.] **********************************************************************************************************************************************************ok: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Ensure RabbitMQ is installed.] *******************************************************************************************************************************************************ok: [1.2.3.4]

TASK [geerlingguy.rabbitmq : Ensure rabbitmq is started and enabled (if configured).] *****************************************************************************************************************************ok: [1.2.3.4]

TASK [database : rabbitmq_user] ***********************************************************************************************************************************************************************************ok: [1.2.3.4]

Ansible Version: ansible 2.5.1

conquester
  • 1,082
  • 2
  • 21
  • 44
  • Can you share the ansible-playbook output? What is your ansible version? – gile Jan 16 '19 at 00:20
  • @gile I have updated the question with the details. – conquester Jan 16 '19 at 01:20
  • You'll have to turn up the logging verbosity to find out what's not happing correctly – mdaniel Jan 16 '19 at 05:46
  • 1
    How did you confirm that the user hasn't been created? If "only" through your attempt to access the Web UI (which I assume means the management interface), then it could be the user you created is not allowed to access it. could you run the following command `rabbitmqctl list_users` and indicate whether the user you expected is present in the list? – Olivier Jan 16 '19 at 12:02
  • @Olivier I know this because my spring-ampq starts a rabbit listener it fails with message that "password authentication PLAIN failed for user: minister", minister is the ansible variable value for rabbitmq_username. ALong with that, I have also added a tag of administrator for this user and I still cannot access the UI. – conquester Jan 17 '19 at 02:10

1 Answers1

0

After much headache, I found the solution to be caused due to difference in the way Windows and Linux handle line endings.

The solution is detailed here.

I don't know why it was being caused in my ansible script, maybe it was due to my particular configuration of editor or something else. But this did solved my issue.

conquester
  • 1,082
  • 2
  • 21
  • 44
  • 1
    Can you clarify how similar your case was to the solution link you provided? If I understand correctly, the user was created, but the password didn't match the one provided in your ansible script? – Olivier Jan 17 '19 at 06:18
  • Yes, when you mentioned to list users using rabbitmqctl then my user was listed. So clearly there was something wrong with the password in my case. – conquester Jan 17 '19 at 07:08