I’ve been developing an AMQP application recently using RabbitMQ. Its control application rabbitmqctl, is allowed to be run by root and rabbitmq users only, which causes a bit of pain every time I want to list queues, exchanges etc. from my regular development shell.
Hence this little hack to allow certain users to run rabbitmqctl. The recipe is for Ubuntu Linux, but should work for any Unix with a pinch of salt.
There’s a group called rabbitmq. We’ll set it up the way all members of this group will be allowed to run rabbitmqctl without pain.
Create
/etc/sudoers.d/rabbitmqctl:# Allow members of `rabbitmq` run `rabbitmqctl` without a password. %rabbitmq ALL=(ALL) NOPASSWD: /usr/sbin/rabbitmqctlFix permissions of this file, or
sudowill carp every time we run it:# chmod 440 /etc/sudoers.d/rabbitmqctlCreate
/etc/profile.d/rabbitmqctl.sh:if [ `id -u` != 0 ]; then alias rabbitmqctl="sudo /usr/sbin/rabbitmqctl" fiAdd intended members to group
rabbitmq. Edit/etc/group:rabbitmq:x:120:alex,bob,carlRe-login as one of group members and give it a try:
$ rabbitmqctl list_vhosts
Should work. If it doesn’t, use the “Comments” box below. :)