-
Notifications
You must be signed in to change notification settings - Fork 1
/
rabbitmq.yaml
47 lines (47 loc) · 2.16 KB
/
rabbitmq.yaml
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
42
43
44
45
46
47
- name: Rabbitmq server
gather_facts: True
hosts: rabbitmq
user: root
vars:
- erlang_cookie: RANDOMSTRINGCOOKIE
tasks:
- name: Install RabbitMQ
yum: name={{item}} state=present
with_items:
- rabbitmq-server
- name: Create rabbitmq /sbin symlink
file: state=link src=//usr/lib/rabbitmq/bin dest=/usr/lib/rabbitmq/sbin
- name: Set erlang cookie
template: src=rabbitmq/erlang.cookie dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400
notify:
- restart rabbitmq
- name: Rabbitmq.config
template: src=rabbitmq/rabbitmq.config dest=/etc/rabbitmq/rabbitmq.config
notify:
- restart rabbitmq
- name: Enable plugins
rabbitmq_plugin: names=rabbitmq_management state=enabled prefix=/usr/lib/rabbitmq/
notify:
- restart rabbitmq
- name: start rabbitmq
service: state=started name=rabbitmq-server enabled=yes
- name: Manage Rabbitmq vhosts on master
rabbitmq_vhost: name={{item.vhost}} state=present
with_items: rabbitmq_vhosts
when: rabbitmq_master is defined
- name: Manage Rabbitmq users on master
rabbitmq_user: name={{item.user}} password={{item.password}} vhost={{item.vhost}} configure_priv=.* read_priv=.* write_priv=.* state=present
with_items: rabbitmq_vhosts
when: rabbitmq_master is defined
# Warning: syntax change between RabbitMQ versions. Default Ansible RabbitMQ module only support recent version of RabbitMQ
- name: Set default policy for HA to all queues/exchanges
rabbitmq_policy: vhost={{item.vhost}} name=HA-{{item.user}} pattern='.*' tags="ha-mode=all" priority=1
with_items: rabbitmq_vhosts
when: rabbitmq_master is defined
- name: Set hostsnames in /etc/hosts
lineinfile: dest=/etc/hosts regexp='.*{{ hostvars[item]['ansible_hostname'] }}$' line="{{ hostvars[item].ansible_default_ipv4.address }} {{hostvars[item]['ansible_hostname']}}" state=present
when: hostvars[item].ansible_default_ipv4.address is defined
with_items: groups['rabbitmq']
handlers:
- name: restart rabbitmq
service: state=restarted name=rabbitmq-server enabled=yes