-
Notifications
You must be signed in to change notification settings - Fork 0
/
fab_rabbitmq.py
38 lines (33 loc) · 1.35 KB
/
fab_rabbitmq.py
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
"""
This recipe will help you to setup RabbitMQ for official repo.
Additionally you can configure Nginx for proxying request to RabbitMQ.
Configuration file: configs/nginx_rabbitmq.conf
usage:
fab -f fab_rabbitmq.py -H <hostname> setup_rabbitmq
"""
from fabric.api import task, sudo, cd, prompt
@task
def setup_rabbitmq():
"""
Setup and configure RabbitMQ
"""
# add official repository to sources.list
sudo('echo \'deb http://www.rabbitmq.com/debian/ testing main \' '\
'> /etc/apt/sources.list.d/rabbitmq.list')
with cd('/tmp'):
sudo('wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc')
sudo('apt-key add rabbitmq-signing-key-public.asc')
sudo('rm rabbitmq-signing-key-public.asc')
sudo('apt-get update')
sudo('apt-get -y install rabbitmq-server')
# Create new superuser, to replace old one (guest)
login = prompt("RabbitMQ Administrator login: ")
passwd = prompt("RabbitMQ Administrator password: ")
sudo('rabbitmqctl add_user %s %s' % (login, passwd))
sudo('rabbitmqctl set_user_tags karma administrator')
sudo('rabbitmqctl set_permissions karma ".*" ".*" ".*"')
sudo('rabbitmqctl delete_user guest')
# ulimit -n 1024
# Turn on web console(management plugin)
sudo('rabbitmq-plugins enable rabbitmq_management')
sudo('/etc/init.d/rabbitmq-server restart')