1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#!/usr/bin/env ruby
$ctl = ENV["AMQP_GEM_RABBITMQCTL"] || ENV["RABBITMQCTL"] || "sudo rabbitmqctl"
$plugins = ENV["AMQP_GEM_RABBITMQ_PLUGINS"] || ENV["RABBITMQ_PLUGINS"] || "sudo rabbitmq-plugins"
def rabbit_control(args)
command = "#{$ctl} #{args}"
system command
end
def rabbit_plugins(args)
command = "#{$plugins} #{args}"
system command
end
# guest:guest has full access to /
rabbit_control 'add_vhost /'
rabbit_control 'add_user guest guest'
rabbit_control 'set_permissions -p / guest ".*" ".*" ".*"'
# amqp_gem:amqp_gem_password has full access to amqp_gem_testbed
rabbit_control 'add_vhost amqp_gem_testbed'
rabbit_control 'add_user amqp_gem amqp_gem_password'
rabbit_control 'set_permissions -p amqp_gem_testbed amqp_gem ".*" ".*" ".*"'
# amqp_gem_reader:reader_password has read access to amqp_gem_testbed
rabbit_control 'add_user amqp_gem_reader reader_password'
rabbit_control 'clear_permissions -p amqp_gem_testbed guest'
rabbit_control 'set_permissions -p amqp_gem_testbed amqp_gem_reader "^---$" "^---$" ".*"'
# requires RabbitMQ 3.0+
# $RABBITMQ_PLUGINS enable rabbitmq_consistent_hash_exchange
# Reduce retention policy for faster publishing of stats
rabbit_control "eval 'supervisor2:terminate_child(rabbit_mgmt_sup_sup, rabbit_mgmt_sup), application:set_env(rabbitmq_management, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_sup_sup:start_child().'"
rabbit_control "eval 'supervisor2:terminate_child(rabbit_mgmt_agent_sup_sup, rabbit_mgmt_agent_sup), application:set_env(rabbitmq_management_agent, sample_retention_policies, [{global, [{605, 1}]}, {basic, [{605, 1}]}, {detailed, [{10, 1}]}]), rabbit_mgmt_agent_sup_sup:start_child().'"
|