Is there a way to check if a rmq user already exists?

483 views
Skip to first unread message

Renya Walker

unread,
Feb 28, 2020, 6:51:54 AM2/28/20
to rabbitmq-users
Hello all again, 

I'm currently working on a rabbitmq set up application for our app. A brief description for our setup application is that, it reads an xml that contains the rabbitmq commands and then runs them silently - for example, rabbitmqctl add_user "myuser" "myuserspassword1".

On first run of our setup application, everything runs smoothly. However, when you run it again given the same xml, it will naturally generate a "user already exists" error - which is expected. Maybe this is far fetched, but is there a way we can check if a user already exists? I've looked around in the web but it seemed there's no article about it. 

Here's my development environment: 
OS: Windows 10 Pro
RMQ: 3.8.2
Erlang: 10.5 OTP 22

Best regards,

Wesley Peng

unread,
Feb 28, 2020, 7:18:21 AM2/28/20
to rabbitm...@googlegroups.com
Yes rabbitmqctl can list the existing users.

Regards 

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/00698968-5950-4ae8-8158-cd39da90e7f6%40googlegroups.com.

Michael Klishin

unread,
Feb 28, 2020, 2:12:53 PM2/28/20
to rabbitmq-users
Listing users is the only way at the moment.

What I personally think should happen is `add_user` should be made idempotent. Re-adding an existing user
arguably should not be an error. I see the argument that it would open the door to certain new misconfigurations such as mismatching credentials
but I'd believe that it is a common scenario when I see it. It can be a new CLI command flag.

If you want to preconfigure a node, consider using definition import [1]. In 3.8.2 it can be done without management
plugin (management.load_definitions becomes just load_definitions in the config file), including using CLI tools.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/00698968-5950-4ae8-8158-cd39da90e7f6%40googlegroups.com.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Renya Walker

unread,
Mar 2, 2020, 12:51:25 AM3/2/20
to rabbitmq-users
Hello Michael, 

Thank you for your reply. Right now I just made a workaround in my rabbitmq setup application - to satisfy our current requirement. We are currently thinking if it's better to have the RMQ user setup on the fly - no more putting the user credentials in an XML. Thank you for clarifying that listing users is the only way to know if the user exists at the moment. 

Also, if it's worth to know - I'm using RMQ .Net Client. :)

Best regards,

Renya


On Saturday, February 29, 2020 at 3:12:53 AM UTC+8, Michael Klishin wrote:
Listing users is the only way at the moment.

What I personally think should happen is `add_user` should be made idempotent. Re-adding an existing user
arguably should not be an error. I see the argument that it would open the door to certain new misconfigurations such as mismatching credentials
but I'd believe that it is a common scenario when I see it. It can be a new CLI command flag.

If you want to preconfigure a node, consider using definition import [1]. In 3.8.2 it can be done without management
plugin (management.load_definitions becomes just load_definitions in the config file), including using CLI tools.


On Fri, Feb 28, 2020 at 2:52 PM Renya Walker <tomoem...@gmail.com> wrote:
Hello all again, 

I'm currently working on a rabbitmq set up application for our app. A brief description for our setup application is that, it reads an xml that contains the rabbitmq commands and then runs them silently - for example, rabbitmqctl add_user "myuser" "myuserspassword1".

On first run of our setup application, everything runs smoothly. However, when you run it again given the same xml, it will naturally generate a "user already exists" error - which is expected. Maybe this is far fetched, but is there a way we can check if a user already exists? I've looked around in the web but it seemed there's no article about it. 

Here's my development environment: 
OS: Windows 10 Pro
RMQ: 3.8.2
Erlang: 10.5 OTP 22

Best regards,

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitm...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages