1. Runnning RabbitMQ’s `rabbitmqctl` as non-root

    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/rabbitmqctl
      
    • Fix permissions of this file, or sudo will carp every time we run it:

      # chmod 440 /etc/sudoers.d/rabbitmqctl
      
    • Create /etc/profile.d/rabbitmqctl.sh:

      if [ `id -u` != 0 ]; then
        alias rabbitmqctl="sudo /usr/sbin/rabbitmqctl"
      fi
      
    • Add intended members to group rabbitmq. Edit /etc/group:

      rabbitmq:x:120:alex,bob,carl
      
    • Re-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. :)

     
    1. shashikant86 reblogged this from dadooda
    2. dadooda posted this