aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2017-05-20 21:23:32 -0400
committerGitHub <noreply@github.com>2017-05-20 21:23:32 -0400
commite21afd9063945e9825e4fe541244bc788a15590f (patch)
tree2971e931788eddf51b9ec71ac063bfb951215d0c
parent3a55d2ab8ab3a399faaf25c4f46e7f2ea142edc6 (diff)
parenta67dde50f26e0f76d91f0744e8e8341dac95dae2 (diff)
downloadansible-rabbitmq-e21afd9063945e9825e4fe541244bc788a15590f.tar.gz
ansible-rabbitmq-e21afd9063945e9825e4fe541244bc788a15590f.tar.zst
ansible-rabbitmq-e21afd9063945e9825e4fe541244bc788a15590f.zip
Merge pull request #12 from mrlesmithjr/enhancements/issues-9-10-11
Enhancements/issues 9 10 11
-rw-r--r--README.md92
-rw-r--r--defaults/main.yml47
-rw-r--r--handlers/main.yml1
-rw-r--r--playbook.yml25
-rw-r--r--requirements.yml1
-rw-r--r--tasks/config.yml7
-rw-r--r--tasks/debian.yml6
-rw-r--r--tasks/fedora.yml7
-rw-r--r--tasks/main.yml17
-rw-r--r--tasks/rabbitmq_clustering.yml56
-rw-r--r--tasks/rabbitmq_ha_config.yml27
-rw-r--r--tasks/rabbitmq_users.yml39
-rw-r--r--tasks/redhat.yml7
-rw-r--r--templates/etc/rabbitmq/rabbitmq.config677
-rw-r--r--templates/etc/rabbitmq/rabbitmq.config.j29
15 files changed, 865 insertions, 153 deletions
diff --git a/README.md b/README.md
index 99c019d..b3b03ad 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
1Role Name 1Role Name
2========= 2=========
3 3
4Installs rabbitmq https://www.rabbitmq.com/ (Configurable...HA and Clustering ready) 4An [Ansible] role to install/configure [RabbitMQ]
5 5
6Build Status 6Build Status
7------------ 7------------
@@ -11,67 +11,30 @@ Build Status
11Requirements 11Requirements
12------------ 12------------
13 13
14Ensure hostnames are resolvable prior to clustering...either update /etc/hosts or ensure DNS is working. 14Ensure hostnames are resolvable prior to clustering...either update /etc/hosts
15or ensure DNS is working.
15 16
16Vagrant 17Vagrant
17------- 18-------
18 19
19Spin up a 3 node HA Cluster for testing... 20Spin up a 3 node HA Cluster for testing...
20Install Ansible role on your host: 21Install Ansible role on your host:
21```` 22```
22sudo ansible-galaxy install -r requirements.yml -f 23sudo ansible-galaxy install -r requirements.yml -f
23```` 24```
24Now spin up your environment... 25Now spin up your environment...
25```` 26```
26vagrant up 27vagrant up
27```` 28```
28When you are done testing, tear it all down... 29When you are done testing, tear it all down...
29```` 30```
30./cleanup.sh 31./cleanup.sh
31```` 32```
32 33
33Role Variables 34Role Variables
34-------------- 35--------------
35 36
36```` 37[Role Defaults](./defaults/main.yml)
37---
38# defaults file for ansible-rabbitmq
39rabbitmq_config_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
40rabbitmq_enable_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
41rabbitmq_erlang_cookie: 'LSKNKBELKPSTDBBCHETL' #define erlang cookie for cluster...define here or in group_vars/group
42rabbitmq_erlang_cookie_file: '/var/lib/rabbitmq/.erlang.cookie'
43rabbitmq_config:
44 - queue_name: logstash
45 durable: true
46 exchange_name: logstash
47 type: direct
48 routing_key: logstash
49 tags: 'ha-mode=all,ha-sync-mode=automatic'
50rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main'
51rabbitmq_debian_repo_key: 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
52rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
53rabbitmq_redhat_repo_key: 'https://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
54rabbitmq_redhat_package: 'rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch.rpm'
55rabbitmq_redhat_url: 'http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}'
56rabbitmq_redhat_version: '3.6.1'
57rabbitmq_users: #define admin user to create in order to login to WebUI
58 - name: rabbitmqadmin
59 password: rabbitmqadmin
60 vhost: /
61 configure_priv: '.*'
62 read_priv: '.*'
63 write_priv: '.*'
64 tags: 'administrator' #define comma separated list of tags to assign to user....management,policymaker,monitoring,administrator...required for management plugin. https://www.rabbitmq.com/management.html
65````
66
67example...
68group_vars/rabbitmq-cluster-nodes
69````
70---
71rabbitmq_enable_clustering: true
72rabbitmq_config_ha: false
73rabbitmq_master: ans-test-1
74````
75 38
76Dependencies 39Dependencies
77------------ 40------------
@@ -81,33 +44,7 @@ None
81Example Playbook 44Example Playbook
82---------------- 45----------------
83 46
84```` 47[Example Playbook](./playbook.yml)
85---
86- hosts: all
87 become: true
88 vars:
89 - pri_domain_name: 'test.vagrant.local'
90 roles:
91 tasks:
92 - name: updating /etc/hosts
93 lineinfile:
94 dest: /etc/hosts
95 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
96 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
97 state: present
98 with_items: "{{ groups['all'] }}"
99
100- hosts: all
101 become: true
102 vars:
103 - rabbitmq_config_ha: true
104 - rabbitmq_enable_clustering: true
105 - pri_domain_name: 'test.vagrant.local'
106 - rabbitmq_master: 'node0'
107 roles:
108 - role: ansible-rabbitmq
109 tasks:
110````
111 48
112License 49License
113------- 50-------
@@ -118,6 +55,11 @@ Author Information
118------------------ 55------------------
119 56
120Larry Smith Jr. 57Larry Smith Jr.
121- @mrlesmithjr 58- [@mrlesmithjr]
122- http://everythingshouldbevirtual.com 59- http://everythingshouldbevirtual.com
123- mrlesmithjr [at] gmail.com 60- mrlesmithjr [at] gmail.com
61
62[@mrlesmithjr]: <https://www.twitter.com/mrlesmithjr>
63
64[Ansible]: <https://www.ansible.com>
65[RabbitMQ]: <https://www.rabbitmq.com/>
diff --git a/defaults/main.yml b/defaults/main.yml
index ad22ead..90d7fb5 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,28 +1,49 @@
1--- 1---
2# defaults file for ansible-rabbitmq 2# defaults file for ansible-rabbitmq
3rabbitmq_config: 3rabbitmq_config: []
4 - queue_name: 'logstash' 4 # - queue_name: 'logstash'
5 durable: true 5 # durable: true
6 exchange_name: logstash 6 # exchange_name: logstash
7 type: 'direct' 7 # type: 'direct'
8 routing_key: 'logstash' 8 # routing_key: 'logstash'
9 tags: 'ha-mode=all,ha-sync-mode=automatic' 9 # tags: 'ha-mode=all,ha-sync-mode=automatic'
10rabbitmq_config_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group 10
11# Defines if rabbitmq ha should be configured
12rabbitmq_config_ha: false
13
14rabbitmq_config_service: false
15
11rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main' 16rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main'
12rabbitmq_debian_repo_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc' 17rabbitmq_debian_repo_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc'
13rabbitmq_enable_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group 18
14rabbitmq_erlang_cookie: 'LSKNKBELKPSTDBBCHETL' #define erlang cookie for cluster...define here or in group_vars/group 19# Defines if setting up a rabbitmq cluster
20rabbitmq_enable_clustering: false
21
15rabbitmq_erlang_cookie_file: '/var/lib/rabbitmq/.erlang.cookie' 22rabbitmq_erlang_cookie_file: '/var/lib/rabbitmq/.erlang.cookie'
16rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group 23
24rabbitmq_listen_port: 5672
25rabbitmq_listeners: []
26 # - '127.0.0.1'
27 # - '::1'
28
29# Defines the inventory host that should be considered master
30rabbitmq_master: []
31
17rabbitmq_redhat_repo_key: 'https://www.rabbitmq.com/rabbitmq-signing-key-public.asc' 32rabbitmq_redhat_repo_key: 'https://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
18rabbitmq_redhat_package: 'rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch.rpm' 33rabbitmq_redhat_package: 'rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch.rpm'
19rabbitmq_redhat_url: 'http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}' 34rabbitmq_redhat_url: 'http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}'
20rabbitmq_redhat_version: '3.6.1' 35rabbitmq_redhat_version: '3.6.1'
21rabbitmq_users: #define admin user to create in order to login to WebUI 36
37# Define admin user to create in order to login to WebUI
38rabbitmq_users:
22 - name: 'rabbitmqadmin' 39 - name: 'rabbitmqadmin'
23 password: 'rabbitmqadmin' 40 password: 'rabbitmqadmin'
24 vhost: '/' 41 vhost: '/'
25 configure_priv: '.*' 42 configure_priv: '.*'
26 read_priv: '.*' 43 read_priv: '.*'
27 write_priv: '.*' 44 write_priv: '.*'
28 tags: 'administrator' #define comma separated list of tags to assign to user....management,policymaker,monitoring,administrator...required for management plugin. https://www.rabbitmq.com/management.html 45 # Define comma separated list of tags to assign to user:
46 # management,policymaker,monitoring,administrator
47 # required for management plugin.
48 # https://www.rabbitmq.com/management.html
49 tags: 'administrator'
diff --git a/handlers/main.yml b/handlers/main.yml
index 259ce1c..4fdafe5 100644
--- a/handlers/main.yml
+++ b/handlers/main.yml
@@ -4,3 +4,4 @@
4 service: 4 service:
5 name: "rabbitmq-server" 5 name: "rabbitmq-server"
6 state: restarted 6 state: restarted
7 become: true
diff --git a/playbook.yml b/playbook.yml
index 1968320..4936577 100644
--- a/playbook.yml
+++ b/playbook.yml
@@ -1,25 +1,12 @@
1--- 1---
2- hosts: all 2- hosts: rabbitmq_cluster
3 become: true
4 vars: 3 vars:
5 pri_domain_name: 'test.vagrant.local' 4 etc_hosts_add_all_hosts: true
6 roles: 5 etc_hosts_pri_dns_name: '{{ pri_domain_name }}'
7 tasks: 6 pri_domain_name: 'vagrant.local'
8 - name: updating /etc/hosts
9 lineinfile:
10 dest: /etc/hosts
11 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
12 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
13 state: present
14 with_items: "{{ groups['all'] }}"
15
16- hosts: all
17 become: true
18 vars:
19 pri_domain_name: 'test.vagrant.local'
20 rabbitmq_config_ha: true
21 rabbitmq_enable_clustering: true 7 rabbitmq_enable_clustering: true
22 rabbitmq_master: 'node0' 8 rabbitmq_master: "{{ groups['rabbitmq_cluster'][0] }}"
23 roles: 9 roles:
10 - role: ansible-etc-hosts
24 - role: ansible-rabbitmq 11 - role: ansible-rabbitmq
25 tasks: 12 tasks:
diff --git a/requirements.yml b/requirements.yml
index a1f51cb..ce92d72 100644
--- a/requirements.yml
+++ b/requirements.yml
@@ -1,2 +1,3 @@
1--- 1---
2- src: https://github.com/mrlesmithjr/ansible-etc-hosts.git
2- src: https://github.com/mrlesmithjr/ansible-rabbitmq.git 3- src: https://github.com/mrlesmithjr/ansible-rabbitmq.git
diff --git a/tasks/config.yml b/tasks/config.yml
new file mode 100644
index 0000000..9ea5da2
--- /dev/null
+++ b/tasks/config.yml
@@ -0,0 +1,7 @@
1---
2- name: config | Configuring RabbitMQ
3 template:
4 src: "etc/rabbitmq/rabbitmq.config.j2"
5 dest: "/etc/rabbitmq/rabbitmq.config"
6 become: true
7 notify: "restart rabbitmq-server"
diff --git a/tasks/debian.yml b/tasks/debian.yml
index a031ead..b25d39b 100644
--- a/tasks/debian.yml
+++ b/tasks/debian.yml
@@ -3,22 +3,26 @@
3 apt_key: 3 apt_key:
4 url: "{{ rabbitmq_debian_repo_key }}" 4 url: "{{ rabbitmq_debian_repo_key }}"
5 state: present 5 state: present
6 become: true
6 7
7- name: debian | adding RabbitMQ repo 8- name: debian | adding RabbitMQ repo
8 apt_repository: 9 apt_repository:
9 repo: "{{ rabbitmq_debian_repo }}" 10 repo: "{{ rabbitmq_debian_repo }}"
10 state: present 11 state: present
11 register: "rabbitmq_repo_added" 12 register: "rabbitmq_repo_added"
13 become: true
12 14
13- name: debian | updating apt cache 15- name: debian | updating apt cache
14 apt: 16 apt:
15 update_cache: yes 17 update_cache: yes
18 become: true
16 when: rabbitmq_repo_added.changed 19 when: rabbitmq_repo_added.changed
17 20
18- name: debian | installing RabbitMQ server 21- name: debian | installing RabbitMQ server
19 apt: 22 apt:
20 name: "{{ item }}" 23 name: "{{ item }}"
21 state: present 24 state: present
25 become: true
22 with_items: 26 with_items:
23 - rabbitmq-server 27 - rabbitmq-server
24 28
@@ -26,6 +30,7 @@
26 rabbitmq_plugin: 30 rabbitmq_plugin:
27 names: rabbitmq_management 31 names: rabbitmq_management
28 state: enabled 32 state: enabled
33 become: true
29 notify: restart rabbitmq-server 34 notify: restart rabbitmq-server
30 35
31- name: debian | ensuring that the RabbitMQ service is running 36- name: debian | ensuring that the RabbitMQ service is running
@@ -33,3 +38,4 @@
33 name: rabbitmq-server 38 name: rabbitmq-server
34 state: started 39 state: started
35 enabled: yes 40 enabled: yes
41 become: true
diff --git a/tasks/fedora.yml b/tasks/fedora.yml
index 3d92963..6ac9c03 100644
--- a/tasks/fedora.yml
+++ b/tasks/fedora.yml
@@ -3,6 +3,7 @@
3 dnf: 3 dnf:
4 name: "{{ item }}" 4 name: "{{ item }}"
5 state: present 5 state: present
6 become: true
6 with_items: 7 with_items:
7 - wget 8 - wget
8 9
@@ -10,30 +11,36 @@
10 dnf: 11 dnf:
11 name: "erlang" 12 name: "erlang"
12 state: present 13 state: present
14 become: true
13 15
14- name: fedora | adding RabbitMQ public GPG key 16- name: fedora | adding RabbitMQ public GPG key
15 rpm_key: 17 rpm_key:
16 key: "{{ rabbitmq_redhat_repo_key }}" 18 key: "{{ rabbitmq_redhat_repo_key }}"
17 state: present 19 state: present
20 become: true
18 21
19- name: fedora | downloading RabbitMQ 22- name: fedora | downloading RabbitMQ
20 get_url: 23 get_url:
21 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" 24 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
22 dest: "/opt/{{ rabbitmq_redhat_package }}" 25 dest: "/opt/{{ rabbitmq_redhat_package }}"
26 become: true
23 27
24- name: fedora | installing RabbitMQ 28- name: fedora | installing RabbitMQ
25 dnf: 29 dnf:
26 name: "/opt/{{ rabbitmq_redhat_package }}" 30 name: "/opt/{{ rabbitmq_redhat_package }}"
27 state: present 31 state: present
32 become: true
28 33
29- name: fedora | starting and enabling RabbitMQ service 34- name: fedora | starting and enabling RabbitMQ service
30 service: 35 service:
31 name: "rabbitmq-server" 36 name: "rabbitmq-server"
32 state: started 37 state: started
33 enabled: yes 38 enabled: yes
39 become: true
34 40
35- name: fedora | enabling the RabbitMQ Management Console 41- name: fedora | enabling the RabbitMQ Management Console
36 rabbitmq_plugin: 42 rabbitmq_plugin:
37 names: rabbitmq_management 43 names: rabbitmq_management
38 state: enabled 44 state: enabled
39 notify: restart rabbitmq-server 45 notify: restart rabbitmq-server
46 become: true
diff --git a/tasks/main.yml b/tasks/main.yml
index bd82f93..1da06c4 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -3,19 +3,30 @@
3 when: ansible_os_family == "Debian" 3 when: ansible_os_family == "Debian"
4 4
5- include: redhat.yml 5- include: redhat.yml
6 when: ansible_distribution == "CentOS" or ansible_distribution == "Red Hat Enterprise Linux" 6 when: >
7 ansible_distribution == "CentOS" or
8 ansible_distribution == "Red Hat Enterprise Linux"
7 9
8- include: fedora.yml 10- include: fedora.yml
9 when: ansible_distribution == "Fedora" 11 when: ansible_distribution == "Fedora"
10 12
13- include: config.yml
14 when: rabbitmq_config_service
15
11- name: checking to see if already clustered 16- name: checking to see if already clustered
12 stat: path=/etc/rabbitmq/clustered 17 stat: path=/etc/rabbitmq/clustered
13 register: clustered 18 register: clustered
14 19
15- include: rabbitmq_clustering.yml 20- include: rabbitmq_clustering.yml
16 when: rabbitmq_enable_clustering and (clustered.stat.exists != True) 21 when: >
22 rabbitmq_enable_clustering and
23 not clustered['stat']['exists']
17 24
18- include: rabbitmq_ha_config.yml 25- include: rabbitmq_ha_config.yml
19 when: rabbitmq_config_ha and rabbitmq_enable_clustering 26 when: >
27 rabbitmq_config_ha and
28 rabbitmq_enable_clustering and
29 rabbitmq_config is defined
20 30
21- include: rabbitmq_users.yml 31- include: rabbitmq_users.yml
32 when: rabbitmq_users is defined
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml
index 5134c50..9e48590 100644
--- a/tasks/rabbitmq_clustering.yml
+++ b/tasks/rabbitmq_clustering.yml
@@ -1,21 +1,30 @@
1--- 1---
2- name: rabbitmq_clustering | stopping rabbitmq app 2- name: rabbitmq_clustering | stopping rabbitmq app
3 command: rabbitmqctl stop_app 3 command: rabbitmqctl stop_app
4 when: inventory_hostname != "{{ rabbitmq_master }}" 4 become: true
5 when: inventory_hostname != rabbitmq_master
5 6
6- name: rabbitmq_clustering | resetting rabbitmq app 7- name: rabbitmq_clustering | resetting rabbitmq app
7 command: rabbitmqctl reset 8 command: rabbitmqctl reset
8 when: inventory_hostname != "{{ rabbitmq_master }}" 9 become: true
10 when: inventory_hostname != rabbitmq_master
9 11
10- name: rabbitmq_clustering | stopping rabbitmq-server 12- name: rabbitmq_clustering | stopping rabbitmq-server
11 service: 13 service:
12 name: rabbitmq-server 14 name: rabbitmq-server
13 state: stopped 15 state: stopped
16 become: true
14 17
15#- name: grabbing erlang cookie 18- name: rabbitmq_clustering | Capturing Erlang Cookie On Master
16# shell: cat /var/lib/rabbitmq/.erlang.cookie 19 command: "cat {{ rabbitmq_erlang_cookie_file }}"
17# register: rabbitmq_erlang_cookie 20 become: true
18# when: inventory_hostname == "{{ rabbitmq_master }}" 21 register: "rabbitmq_erlang_cookie"
22 when: inventory_hostname == rabbitmq_master
23
24- name: rabbitmq_clustering | Setting Erlang Cookie Of Master on Non-Master
25 set_fact:
26 rabbitmq_erlang_cookie: "{{ hostvars[rabbitmq_master]['rabbitmq_erlang_cookie']['stdout'] }}"
27 when: inventory_hostname != rabbitmq_master
19 28
20- name: rabbitmq_clustering | copy erlang cookie 29- name: rabbitmq_clustering | copy erlang cookie
21 template: 30 template:
@@ -24,49 +33,62 @@
24 owner: rabbitmq 33 owner: rabbitmq
25 group: rabbitmq 34 group: rabbitmq
26 mode: 0400 35 mode: 0400
27 backup: yes #backing up in case the need to recover 36 # backing up in case the need to recover
28# when: inventory_hostname != "{{ rabbitmq_master }}" 37 backup: yes
38 become: true
39 when: inventory_hostname != rabbitmq_master
29 40
30- name: rabbitmq_clustering | restarting rabbitmq-server on master 41- name: rabbitmq_clustering | restarting rabbitmq-server on master
31 service: 42 service:
32 name: rabbitmq-server 43 name: rabbitmq-server
33 state: restarted 44 state: restarted
34 when: inventory_hostname == "{{ rabbitmq_master }}" 45 become: true
46 when: inventory_hostname == rabbitmq_master
35 47
36- name: rabbitmq_clustering | starting rabbitmq app on master 48- name: rabbitmq_clustering | starting rabbitmq app on master
37 command: rabbitmqctl start_app 49 command: rabbitmqctl start_app
38 register: cluster_master 50 register: cluster_master
39 when: inventory_hostname == "{{ rabbitmq_master }}" 51 become: true
52 when: inventory_hostname == rabbitmq_master
40 53
41- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes 54- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
42 shell: pkill -u rabbitmq || true 55 shell: pkill -u rabbitmq || true
43 when: inventory_hostname != "{{ rabbitmq_master }}" 56 become: true
57 when: inventory_hostname != rabbitmq_master
44 58
45- name: rabbitmq_clustering | restarting rabbitmq-server 59- name: rabbitmq_clustering | restarting rabbitmq-server
46 service: 60 service:
47 name: rabbitmq-server 61 name: rabbitmq-server
48 state: restarted 62 state: restarted
49 when: inventory_hostname != "{{ rabbitmq_master }}" 63 become: true
64 when: inventory_hostname != rabbitmq_master
50 65
51- name: rabbitmq_clustering | stopping rabbitmq app 66- name: rabbitmq_clustering | stopping rabbitmq app
52 command: rabbitmqctl stop_app 67 command: rabbitmqctl stop_app
53 when: inventory_hostname != "{{ rabbitmq_master }}" 68 become: true
69 when: inventory_hostname != rabbitmq_master
54 70
55- name: rabbitmq_clustering | resetting rabbitmq app 71- name: rabbitmq_clustering | resetting rabbitmq app
56 command: rabbitmqctl reset 72 command: rabbitmqctl reset
57 when: inventory_hostname != "{{ rabbitmq_master }}" 73 become: true
74 when: inventory_hostname != rabbitmq_master
58 75
59- name: rabbitmq_clustering | joining rabbitmq cluster 76- name: rabbitmq_clustering | joining rabbitmq cluster
60 command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}" 77 command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}"
61 register: cluster_joined 78 register: cluster_joined
62 when: inventory_hostname != "{{ rabbitmq_master }}" 79 become: true
80 when: inventory_hostname != rabbitmq_master
63 81
64- name: rabbitmq_clustering | starting rabbitmq app 82- name: rabbitmq_clustering | starting rabbitmq app
65 command: rabbitmqctl start_app 83 command: rabbitmqctl start_app
66 when: inventory_hostname != "{{ rabbitmq_master }}" 84 become: true
85 when: inventory_hostname != rabbitmq_master
67 86
68- name: rabbitmq_clustering | marking as clustered 87- name: rabbitmq_clustering | marking as clustered
69 file: 88 file:
70 path: /etc/rabbitmq/clustered 89 path: /etc/rabbitmq/clustered
71 state: touch 90 state: touch
72 when: cluster_master.changed or cluster_joined.changed 91 become: true
92 when: >
93 cluster_master['changed'] or
94 cluster_joined['changed']
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
index 8811b6d..bf74957 100644
--- a/tasks/rabbitmq_ha_config.yml
+++ b/tasks/rabbitmq_ha_config.yml
@@ -6,39 +6,46 @@
6 6
7- name: rabbitmq_ha_config | install rabbitMQ admin 7- name: rabbitmq_ha_config | install rabbitMQ admin
8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin 8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin
9 when: not rabbitmqadmin_check.stat.exists 9 become: true
10 when: not rabbitmqadmin_check['stat']['exists']
10 11
11- name: rabbitmq_ha_config | moving the rabbitMQ Admin 12- name: rabbitmq_ha_config | moving the rabbitMQ Admin
12 shell: mv rabbitmqadmin /usr/sbin 13 shell: mv rabbitmqadmin /usr/sbin
13 when: not rabbitmqadmin_check.stat.exists 14 become: true
15 when: not rabbitmqadmin_check['stat']['exists']
14 16
15- name: rabbitmq_ha_config | making executable rabbitMQ Admin 17- name: rabbitmq_ha_config | making executable rabbitMQ Admin
16 shell: chmod +x /usr/sbin/rabbitmqadmin 18 shell: chmod +x /usr/sbin/rabbitmqadmin
17 notify: restart rabbitmq-server 19 notify: restart rabbitmq-server
18 when: not rabbitmqadmin_check.stat.exists 20 become: true
21 when: not rabbitmqadmin_check['stat']['exists']
19 22
20- name: rabbitmq_ha_config | creating queue(s) 23- name: rabbitmq_ha_config | creating queue(s)
21 command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }} 24 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }}
22 run_once: true 25 run_once: true
26 become: true
23 with_items: "{{ rabbitmq_config }}" 27 with_items: "{{ rabbitmq_config }}"
24 28
25- name: rabbitmq_ha_config | setting up ha on queue(s) 29- name: rabbitmq_ha_config | setting up ha on queue(s)
26 rabbitmq_policy: 30 rabbitmq_policy:
27 name: "ha-all" 31 name: "ha-all"
28 pattern: "{{ item.queue_name }}" 32 pattern: "{{ item['queue_name'] }}"
29 tags: "{{ item.tags }}" 33 tags: "{{ item['tags'] }}"
30 state: present 34 state: present
31 run_once: true 35 run_once: true
36 become: true
32 with_items: "{{ rabbitmq_config }}" 37 with_items: "{{ rabbitmq_config }}"
33 38
34- name: rabbitmq_ha_config | creating exchange(s) 39- name: rabbitmq_ha_config | creating exchange(s)
35 command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} 40 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }}
36 run_once: true 41 run_once: true
42 become: true
37 with_items: "{{ rabbitmq_config }}" 43 with_items: "{{ rabbitmq_config }}"
38 when: item.exchange_name is defined 44 when: item['exchange_name'] is defined
39 45
40- name: rabbitmq_ha_config | creating binding(s) 46- name: rabbitmq_ha_config | creating binding(s)
41 command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }} 47 command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }}
42 run_once: true 48 run_once: true
49 become: true
43 with_items: "{{ rabbitmq_config }}" 50 with_items: "{{ rabbitmq_config }}"
44 when: item.exchange_name is defined 51 when: item['exchange_name'] is defined
diff --git a/tasks/rabbitmq_users.yml b/tasks/rabbitmq_users.yml
index 8bce8b2..98e45e2 100644
--- a/tasks/rabbitmq_users.yml
+++ b/tasks/rabbitmq_users.yml
@@ -1,27 +1,34 @@
1--- 1---
2- name: rabbitmq_users | creating rabbitmq users 2- name: rabbitmq_users | creating rabbitmq users
3 rabbitmq_user: 3 rabbitmq_user:
4 name: "{{ item.name }}" 4 name: "{{ item['name'] }}"
5 password: "{{ item.password }}" 5 password: "{{ item['password'] }}"
6 vhost: "{{ item.vhost }}" 6 vhost: "{{ item['vhost'] }}"
7 configure_priv: "{{ item.configure_priv }}" 7 configure_priv: "{{ item['configure_priv'] }}"
8 read_priv: "{{ item.read_priv }}" 8 read_priv: "{{ item['read_priv'] }}"
9 write_priv: "{{ item.write_priv }}" 9 write_priv: "{{ item['write_priv'] }}"
10 tags: "{{ item.tags }}" 10 tags: "{{ item['tags'] }}"
11 state: present 11 state: present
12 become: true
12 with_items: "{{ rabbitmq_users }}" 13 with_items: "{{ rabbitmq_users }}"
13 when: (rabbitmq_enable_clustering is defined and not rabbitmq_enable_clustering) or rabbitmq_enable_clustering is not defined 14 when: >
15 (rabbitmq_enable_clustering is defined and
16 not rabbitmq_enable_clustering) or
17 rabbitmq_enable_clustering is not defined
14 18
15- name: rabbitmq_users | creating rabbitmq users 19- name: rabbitmq_users | creating rabbitmq users
16 rabbitmq_user: 20 rabbitmq_user:
17 name: "{{ item.name }}" 21 name: "{{ item['name'] }}"
18 password: "{{ item.password }}" 22 password: "{{ item['password'] }}"
19 vhost: "{{ item.vhost }}" 23 vhost: "{{ item['vhost'] }}"
20 configure_priv: "{{ item.configure_priv }}" 24 configure_priv: "{{ item['configure_priv'] }}"
21 read_priv: "{{ item.read_priv }}" 25 read_priv: "{{ item['read_priv'] }}"
22 write_priv: "{{ item.write_priv }}" 26 write_priv: "{{ item['write_priv'] }}"
23 tags: "{{ item.tags }}" 27 tags: "{{ item['tags'] }}"
24 state: present 28 state: present
25 run_once: yes 29 run_once: yes
30 become: true
26 with_items: "{{ rabbitmq_users }}" 31 with_items: "{{ rabbitmq_users }}"
27 when: (rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering) 32 when: >
33 rabbitmq_enable_clustering is defined and
34 rabbitmq_enable_clustering
diff --git a/tasks/redhat.yml b/tasks/redhat.yml
index 484597d..afa714c 100644
--- a/tasks/redhat.yml
+++ b/tasks/redhat.yml
@@ -3,6 +3,7 @@
3 yum: 3 yum:
4 name: "{{ item }}" 4 name: "{{ item }}"
5 state: present 5 state: present
6 become: true
6 with_items: 7 with_items:
7 - epel-release 8 - epel-release
8 - wget 9 - wget
@@ -11,30 +12,36 @@
11 yum: 12 yum:
12 name: "erlang" 13 name: "erlang"
13 state: present 14 state: present
15 become: true
14 16
15- name: redhat | adding RabbitMQ public GPG key 17- name: redhat | adding RabbitMQ public GPG key
16 rpm_key: 18 rpm_key:
17 key: "{{ rabbitmq_redhat_repo_key }}" 19 key: "{{ rabbitmq_redhat_repo_key }}"
18 state: present 20 state: present
21 become: true
19 22
20- name: redhat | downloading RabbitMQ 23- name: redhat | downloading RabbitMQ
21 get_url: 24 get_url:
22 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" 25 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
23 dest: "/opt/{{ rabbitmq_redhat_package }}" 26 dest: "/opt/{{ rabbitmq_redhat_package }}"
27 become: true
24 28
25- name: redhat | installing RabbitMQ 29- name: redhat | installing RabbitMQ
26 yum: 30 yum:
27 name: "/opt/{{ rabbitmq_redhat_package }}" 31 name: "/opt/{{ rabbitmq_redhat_package }}"
28 state: present 32 state: present
33 become: true
29 34
30- name: redhat | starting and enabling RabbitMQ service 35- name: redhat | starting and enabling RabbitMQ service
31 service: 36 service:
32 name: "rabbitmq-server" 37 name: "rabbitmq-server"
33 state: started 38 state: started
34 enabled: yes 39 enabled: yes
40 become: true
35 41
36- name: redhat | enabling the RabbitMQ Management Console 42- name: redhat | enabling the RabbitMQ Management Console
37 rabbitmq_plugin: 43 rabbitmq_plugin:
38 names: rabbitmq_management 44 names: rabbitmq_management
39 state: enabled 45 state: enabled
40 notify: restart rabbitmq-server 46 notify: restart rabbitmq-server
47 become: true
diff --git a/templates/etc/rabbitmq/rabbitmq.config b/templates/etc/rabbitmq/rabbitmq.config
new file mode 100644
index 0000000..221da01
--- /dev/null
+++ b/templates/etc/rabbitmq/rabbitmq.config
@@ -0,0 +1,677 @@
1%% -*- mode: erlang -*-
2%% ----------------------------------------------------------------------------
3%% RabbitMQ Sample Configuration File.
4%%
5%% See http://www.rabbitmq.com/configure.html for details.
6%% ----------------------------------------------------------------------------
7[
8 {rabbit,
9 [%%
10 %% Network Connectivity
11 %% ====================
12 %%
13
14 %% By default, RabbitMQ will listen on all interfaces, using
15 %% the standard (reserved) AMQP port.
16 %%
17 %% {tcp_listeners, [5672]},
18
19 %% To listen on a specific interface, provide a tuple of {IpAddress, Port}.
20 %% For example, to listen only on localhost for both IPv4 and IPv6:
21 %%
22 %% {tcp_listeners, [{"127.0.0.1", 5672},
23 %% {"::1", 5672}]},
24
25 %% SSL listeners are configured in the same fashion as TCP listeners,
26 %% including the option to control the choice of interface.
27 %%
28 %% {ssl_listeners, [5671]},
29
30 %% Number of Erlang processes that will accept connections for the TCP
31 %% and SSL listeners.
32 %%
33 %% {num_tcp_acceptors, 10},
34 %% {num_ssl_acceptors, 1},
35
36 %% Maximum time for AMQP 0-8/0-9/0-9-1 handshake (after socket connection
37 %% and SSL handshake), in milliseconds.
38 %%
39 %% {handshake_timeout, 10000},
40
41 %% Log levels (currently just used for connection logging).
42 %% One of 'debug', 'info', 'warning', 'error' or 'none', in decreasing
43 %% order of verbosity. Defaults to 'info'.
44 %%
45 %% {log_levels, [{connection, info}, {channel, info}]},
46
47 %% Set to 'true' to perform reverse DNS lookups when accepting a
48 %% connection. Hostnames will then be shown instead of IP addresses
49 %% in rabbitmqctl and the management plugin.
50 %%
51 %% {reverse_dns_lookups, true},
52
53 %%
54 %% Security / AAA
55 %% ==============
56 %%
57
58 %% The default "guest" user is only permitted to access the server
59 %% via a loopback interface (e.g. localhost).
60 %% {loopback_users, [<<"guest">>]},
61 %%
62 %% Uncomment the following line if you want to allow access to the
63 %% guest user from anywhere on the network.
64 %% {loopback_users, []},
65
66 %% Configuring SSL.
67 %% See http://www.rabbitmq.com/ssl.html for full documentation.
68 %%
69 %% {ssl_options, [{cacertfile, "/path/to/testca/cacert.pem"},
70 %% {certfile, "/path/to/server/cert.pem"},
71 %% {keyfile, "/path/to/server/key.pem"},
72 %% {verify, verify_peer},
73 %% {fail_if_no_peer_cert, false}]},
74
75 %% Choose the available SASL mechanism(s) to expose.
76 %% The two default (built in) mechanisms are 'PLAIN' and
77 %% 'AMQPLAIN'. Additional mechanisms can be added via
78 %% plugins.
79 %%
80 %% See http://www.rabbitmq.com/authentication.html for more details.
81 %%
82 %% {auth_mechanisms, ['PLAIN', 'AMQPLAIN']},
83
84 %% Select an authentication database to use. RabbitMQ comes bundled
85 %% with a built-in auth-database, based on mnesia.
86 %%
87 %% {auth_backends, [rabbit_auth_backend_internal]},
88
89 %% Configurations supporting the rabbitmq_auth_mechanism_ssl and
90 %% rabbitmq_auth_backend_ldap plugins.
91 %%
92 %% NB: These options require that the relevant plugin is enabled.
93 %% See http://www.rabbitmq.com/plugins.html for further details.
94
95 %% The RabbitMQ-auth-mechanism-ssl plugin makes it possible to
96 %% authenticate a user based on the client's SSL certificate.
97 %%
98 %% To use auth-mechanism-ssl, add to or replace the auth_mechanisms
99 %% list with the entry 'EXTERNAL'.
100 %%
101 %% {auth_mechanisms, ['EXTERNAL']},
102
103 %% The rabbitmq_auth_backend_ldap plugin allows the broker to
104 %% perform authentication and authorisation by deferring to an
105 %% external LDAP server.
106 %%
107 %% For more information about configuring the LDAP backend, see
108 %% http://www.rabbitmq.com/ldap.html.
109 %%
110 %% Enable the LDAP auth backend by adding to or replacing the
111 %% auth_backends entry:
112 %%
113 %% {auth_backends, [rabbit_auth_backend_ldap]},
114
115 %% This pertains to both the rabbitmq_auth_mechanism_ssl plugin and
116 %% STOMP ssl_cert_login configurations. See the rabbitmq_stomp
117 %% configuration section later in this file and the README in
118 %% https://github.com/rabbitmq/rabbitmq-auth-mechanism-ssl for further
119 %% details.
120 %%
121 %% To use the SSL cert's CN instead of its DN as the username
122 %%
123 %% {ssl_cert_login_from, common_name},
124
125 %% SSL handshake timeout, in milliseconds.
126 %%
127 %% {ssl_handshake_timeout, 5000},
128
129 %% Password hashing implementation. Will only affect newly
130 %% created users. To recalculate hash for an existing user
131 %% it's necessary to update her password.
132 %%
133 %% {password_hashing_module, rabbit_password_hashing_sha256},
134
135 %% Configuration entry encryption.
136 %% See http://www.rabbitmq.com/configure.html#configuration-encryption
137 %%
138 %% To specify the passphrase in the configuration file:
139 %%
140 %% {config_entry_decoder, [{passphrase, <<"mypassphrase">>}]}
141 %%
142 %% To specify the passphrase in an external file:
143 %%
144 %% {config_entry_decoder, [{passphrase, {file, "/path/to/passphrase/file"}}]}
145 %%
146 %% To make the broker request the passphrase when it starts:
147 %%
148 %% {config_entry_decoder, [{passphrase, prompt}]}
149 %%
150 %% To change encryption settings:
151 %%
152 %% {config_entry_decoder, [{cipher, aes_cbc256},
153 %% {hash, sha512},
154 %% {iterations, 1000}]}
155
156 %%
157 %% Default User / VHost
158 %% ====================
159 %%
160
161 %% On first start RabbitMQ will create a vhost and a user. These
162 %% config items control what gets created. See
163 %% http://www.rabbitmq.com/access-control.html for further
164 %% information about vhosts and access control.
165 %%
166 %% {default_vhost, <<"/">>},
167 %% {default_user, <<"guest">>},
168 %% {default_pass, <<"guest">>},
169 %% {default_permissions, [<<".*">>, <<".*">>, <<".*">>]},
170
171 %% Tags for default user
172 %%
173 %% For more details about tags, see the documentation for the
174 %% Management Plugin at http://www.rabbitmq.com/management.html.
175 %%
176 %% {default_user_tags, [administrator]},
177
178 %%
179 %% Additional network and protocol related configuration
180 %% =====================================================
181 %%
182
183 %% Set the default AMQP heartbeat delay (in seconds).
184 %%
185 %% {heartbeat, 60},
186
187 %% Set the max permissible size of an AMQP frame (in bytes).
188 %%
189 %% {frame_max, 131072},
190
191 %% Set the max frame size the server will accept before connection
192 %% tuning occurs
193 %%
194 %% {initial_frame_max, 4096},
195
196 %% Set the max permissible number of channels per connection.
197 %% 0 means "no limit".
198 %%
199 %% {channel_max, 128},
200
201 %% Customising Socket Options.
202 %%
203 %% See (http://www.erlang.org/doc/man/inet.html#setopts-2) for
204 %% further documentation.
205 %%
206 %% {tcp_listen_options, [{backlog, 128},
207 %% {nodelay, true},
208 %% {exit_on_close, false}]},
209
210 %%
211 %% Resource Limits & Flow Control
212 %% ==============================
213 %%
214 %% See http://www.rabbitmq.com/memory.html for full details.
215
216 %% Memory-based Flow Control threshold.
217 %%
218 %% {vm_memory_high_watermark, 0.4},
219
220 %% Alternatively, we can set a limit (in bytes) of RAM used by the node.
221 %%
222 %% {vm_memory_high_watermark, {absolute, 1073741824}},
223 %%
224 %% Or you can set absolute value using memory units.
225 %%
226 %% {vm_memory_high_watermark, {absolute, "1024M"}},
227 %%
228 %% Supported units suffixes:
229 %%
230 %% k, kiB: kibibytes (2^10 bytes)
231 %% M, MiB: mebibytes (2^20)
232 %% G, GiB: gibibytes (2^30)
233 %% kB: kilobytes (10^3)
234 %% MB: megabytes (10^6)
235 %% GB: gigabytes (10^9)
236
237 %% Fraction of the high watermark limit at which queues start to
238 %% page message out to disc in order to free up memory.
239 %%
240 %% Values greater than 0.9 can be dangerous and should be used carefully.
241 %%
242 %% {vm_memory_high_watermark_paging_ratio, 0.5},
243
244 %% Interval (in milliseconds) at which we perform the check of the memory
245 %% levels against the watermarks.
246 %%
247 %% {memory_monitor_interval, 2500},
248
249 %% Set disk free limit (in bytes). Once free disk space reaches this
250 %% lower bound, a disk alarm will be set - see the documentation
251 %% listed above for more details.
252 %%
253 %% {disk_free_limit, 50000000},
254 %%
255 %% Or you can set it using memory units (same as in vm_memory_high_watermark)
256 %% {disk_free_limit, "50MB"},
257 %% {disk_free_limit, "50000kB"},
258 %% {disk_free_limit, "2GB"},
259
260 %% Alternatively, we can set a limit relative to total available RAM.
261 %%
262 %% Values lower than 1.0 can be dangerous and should be used carefully.
263 %% {disk_free_limit, {mem_relative, 2.0}},
264
265 %%
266 %% Misc/Advanced Options
267 %% =====================
268 %%
269 %% NB: Change these only if you understand what you are doing!
270 %%
271
272 %% To announce custom properties to clients on connection:
273 %%
274 %% {server_properties, []},
275
276 %% How to respond to cluster partitions.
277 %% See http://www.rabbitmq.com/partitions.html for further details.
278 %%
279 %% {cluster_partition_handling, ignore},
280
281 %% Make clustering happen *automatically* at startup - only applied
282 %% to nodes that have just been reset or started for the first time.
283 %% See http://www.rabbitmq.com/clustering.html#auto-config for
284 %% further details.
285 %%
286 %% {cluster_nodes, {['rabbit@my.host.com'], disc}},
287
288 %% Interval (in milliseconds) at which we send keepalive messages
289 %% to other cluster members. Note that this is not the same thing
290 %% as net_ticktime; missed keepalive messages will not cause nodes
291 %% to be considered down.
292 %%
293 %% {cluster_keepalive_interval, 10000},
294
295 %% Set (internal) statistics collection granularity.
296 %%
297 %% {collect_statistics, none},
298
299 %% Statistics collection interval (in milliseconds).
300 %%
301 %% {collect_statistics_interval, 5000},
302
303 %% Explicitly enable/disable hipe compilation.
304 %%
305 %% {hipe_compile, true},
306
307 %% Number of times to retry while waiting for Mnesia tables in a cluster to
308 %% become available.
309 %%
310 %% {mnesia_table_loading_retry_limit, 10},
311
312 %% Time to wait per retry for Mnesia tables in a cluster to become
313 %% available.
314 %%
315 %% {mnesia_table_loading_retry_timeout, 30000},
316
317 %% Size in bytes below which to embed messages in the queue index. See
318 %% http://www.rabbitmq.com/persistence-conf.html
319 %%
320 %% {queue_index_embed_msgs_below, 4096},
321
322 %% Whether or not to enable background GC.
323 %%
324 %% {background_gc_enabled, true},
325 %%
326 %% Interval (in milliseconds) at which we run background GC.
327 %%
328 %% {background_gc_target_interval, 60000}
329
330 ]},
331
332 %% ----------------------------------------------------------------------------
333 %% Advanced Erlang Networking/Clustering Options.
334 %%
335 %% See http://www.rabbitmq.com/clustering.html for details
336 %% ----------------------------------------------------------------------------
337 {kernel,
338 [%% Sets the net_kernel tick time.
339 %% Please see http://erlang.org/doc/man/kernel_app.html and
340 %% http://www.rabbitmq.com/nettick.html for further details.
341 %%
342 %% {net_ticktime, 60}
343 ]},
344
345 %% ----------------------------------------------------------------------------
346 %% RabbitMQ Management Plugin
347 %%
348 %% See http://www.rabbitmq.com/management.html for details
349 %% ----------------------------------------------------------------------------
350
351 {rabbitmq_management,
352 [%% Pre-Load schema definitions from the following JSON file. See
353 %% http://www.rabbitmq.com/management.html#load-definitions
354 %%
355 %% {load_definitions, "/path/to/schema.json"},
356
357 %% Log all requests to the management HTTP API to a file.
358 %%
359 %% {http_log_dir, "/path/to/access.log"},
360
361 %% Change the port on which the HTTP listener listens,
362 %% specifying an interface for the web server to bind to.
363 %% Also set the listener to use SSL and provide SSL options.
364 %%
365 %% {listener, [{port, 12345},
366 %% {ip, "127.0.0.1"},
367 %% {ssl, true},
368 %% {ssl_opts, [{cacertfile, "/path/to/cacert.pem"},
369 %% {certfile, "/path/to/cert.pem"},
370 %% {keyfile, "/path/to/key.pem"}]}]},
371
372 %% One of 'basic', 'detailed' or 'none'. See
373 %% http://www.rabbitmq.com/management.html#fine-stats for more details.
374 %% {rates_mode, basic},
375
376 %% Configure how long aggregated data (such as message rates and queue
377 %% lengths) is retained. Please read the plugin's documentation in
378 %% http://www.rabbitmq.com/management.html#configuration for more
379 %% details.
380 %%
381 %% {sample_retention_policies,
382 %% [{global, [{60, 5}, {3600, 60}, {86400, 1200}]},
383 %% {basic, [{60, 5}, {3600, 60}]},
384 %% {detailed, [{10, 5}]}]}
385 ]},
386
387 %% ----------------------------------------------------------------------------
388 %% RabbitMQ Shovel Plugin
389 %%
390 %% See http://www.rabbitmq.com/shovel.html for details
391 %% ----------------------------------------------------------------------------
392
393 {rabbitmq_shovel,
394 [{shovels,
395 [%% A named shovel worker.
396 %% {my_first_shovel,
397 %% [
398
399 %% List the source broker(s) from which to consume.
400 %%
401 %% {sources,
402 %% [%% URI(s) and pre-declarations for all source broker(s).
403 %% {brokers, ["amqp://user:password@host.domain/my_vhost"]},
404 %% {declarations, []}
405 %% ]},
406
407 %% List the destination broker(s) to publish to.
408 %% {destinations,
409 %% [%% A singular version of the 'brokers' element.
410 %% {broker, "amqp://"},
411 %% {declarations, []}
412 %% ]},
413
414 %% Name of the queue to shovel messages from.
415 %%
416 %% {queue, <<"your-queue-name-goes-here">>},
417
418 %% Optional prefetch count.
419 %%
420 %% {prefetch_count, 10},
421
422 %% when to acknowledge messages:
423 %% - no_ack: never (auto)
424 %% - on_publish: after each message is republished
425 %% - on_confirm: when the destination broker confirms receipt
426 %%
427 %% {ack_mode, on_confirm},
428
429 %% Overwrite fields of the outbound basic.publish.
430 %%
431 %% {publish_fields, [{exchange, <<"my_exchange">>},
432 %% {routing_key, <<"from_shovel">>}]},
433
434 %% Static list of basic.properties to set on re-publication.
435 %%
436 %% {publish_properties, [{delivery_mode, 2}]},
437
438 %% The number of seconds to wait before attempting to
439 %% reconnect in the event of a connection failure.
440 %%
441 %% {reconnect_delay, 2.5}
442
443 %% ]} %% End of my_first_shovel
444 ]}
445 %% Rather than specifying some values per-shovel, you can specify
446 %% them for all shovels here.
447 %%
448 %% {defaults, [{prefetch_count, 0},
449 %% {ack_mode, on_confirm},
450 %% {publish_fields, []},
451 %% {publish_properties, [{delivery_mode, 2}]},
452 %% {reconnect_delay, 2.5}]}
453 ]},
454
455 %% ----------------------------------------------------------------------------
456 %% RabbitMQ Stomp Adapter
457 %%
458 %% See http://www.rabbitmq.com/stomp.html for details
459 %% ----------------------------------------------------------------------------
460
461 {rabbitmq_stomp,
462 [%% Network Configuration - the format is generally the same as for the broker
463
464 %% Listen only on localhost (ipv4 & ipv6) on a specific port.
465 %% {tcp_listeners, [{"127.0.0.1", 61613},
466 %% {"::1", 61613}]},
467
468 %% Listen for SSL connections on a specific port.
469 %% {ssl_listeners, [61614]},
470
471 %% Number of Erlang processes that will accept connections for the TCP
472 %% and SSL listeners.
473 %%
474 %% {num_tcp_acceptors, 10},
475 %% {num_ssl_acceptors, 1},
476
477 %% Additional SSL options
478
479 %% Extract a name from the client's certificate when using SSL.
480 %%
481 %% {ssl_cert_login, true},
482
483 %% Set a default user name and password. This is used as the default login
484 %% whenever a CONNECT frame omits the login and passcode headers.
485 %%
486 %% Please note that setting this will allow clients to connect without
487 %% authenticating!
488 %%
489 %% {default_user, [{login, "guest"},
490 %% {passcode, "guest"}]},
491
492 %% If a default user is configured, or you have configured use SSL client
493 %% certificate based authentication, you can choose to allow clients to
494 %% omit the CONNECT frame entirely. If set to true, the client is
495 %% automatically connected as the default user or user supplied in the
496 %% SSL certificate whenever the first frame sent on a session is not a
497 %% CONNECT frame.
498 %%
499 %% {implicit_connect, true}
500 ]},
501
502 %% ----------------------------------------------------------------------------
503 %% RabbitMQ MQTT Adapter
504 %%
505 %% See https://github.com/rabbitmq/rabbitmq-mqtt/blob/stable/README.md
506 %% for details
507 %% ----------------------------------------------------------------------------
508
509 {rabbitmq_mqtt,
510 [%% Set the default user name and password. Will be used as the default login
511 %% if a connecting client provides no other login details.
512 %%
513 %% Please note that setting this will allow clients to connect without
514 %% authenticating!
515 %%
516 %% {default_user, <<"guest">>},
517 %% {default_pass, <<"guest">>},
518
519 %% Enable anonymous access. If this is set to false, clients MUST provide
520 %% login information in order to connect. See the default_user/default_pass
521 %% configuration elements for managing logins without authentication.
522 %%
523 %% {allow_anonymous, true},
524
525 %% If you have multiple chosts, specify the one to which the
526 %% adapter connects.
527 %%
528 %% {vhost, <<"/">>},
529
530 %% Specify the exchange to which messages from MQTT clients are published.
531 %%
532 %% {exchange, <<"amq.topic">>},
533
534 %% Specify TTL (time to live) to control the lifetime of non-clean sessions.
535 %%
536 %% {subscription_ttl, 1800000},
537
538 %% Set the prefetch count (governing the maximum number of unacknowledged
539 %% messages that will be delivered).
540 %%
541 %% {prefetch, 10},
542
543 %% TCP/SSL Configuration (as per the broker configuration).
544 %%
545 %% {tcp_listeners, [1883]},
546 %% {ssl_listeners, []},
547
548 %% Number of Erlang processes that will accept connections for the TCP
549 %% and SSL listeners.
550 %%
551 %% {num_tcp_acceptors, 10},
552 %% {num_ssl_acceptors, 1},
553
554 %% TCP/Socket options (as per the broker configuration).
555 %%
556 %% {tcp_listen_options, [{backlog, 128},
557 %% {nodelay, true}]}
558 ]},
559
560 %% ----------------------------------------------------------------------------
561 %% RabbitMQ AMQP 1.0 Support
562 %%
563 %% See https://github.com/rabbitmq/rabbitmq-amqp1.0/blob/stable/README.md
564 %% for details
565 %% ----------------------------------------------------------------------------
566
567 {rabbitmq_amqp1_0,
568 [%% Connections that are not authenticated with SASL will connect as this
569 %% account. See the README for more information.
570 %%
571 %% Please note that setting this will allow clients to connect without
572 %% authenticating!
573 %%
574 %% {default_user, "guest"},
575
576 %% Enable protocol strict mode. See the README for more information.
577 %%
578 %% {protocol_strict_mode, false}
579 ]},
580
581 %% ----------------------------------------------------------------------------
582 %% RabbitMQ LDAP Plugin
583 %%
584 %% See http://www.rabbitmq.com/ldap.html for details.
585 %%
586 %% ----------------------------------------------------------------------------
587
588 {rabbitmq_auth_backend_ldap,
589 [%%
590 %% Connecting to the LDAP server(s)
591 %% ================================
592 %%
593
594 %% Specify servers to bind to. You *must* set this in order for the plugin
595 %% to work properly.
596 %%
597 %% {servers, ["your-server-name-goes-here"]},
598
599 %% Connect to the LDAP server using SSL
600 %%
601 %% {use_ssl, false},
602
603 %% Specify the LDAP port to connect to
604 %%
605 %% {port, 389},
606
607 %% LDAP connection timeout, in milliseconds or 'infinity'
608 %%
609 %% {timeout, infinity},
610
611 %% Enable logging of LDAP queries.
612 %% One of
613 %% - false (no logging is performed)
614 %% - true (verbose logging of the logic used by the plugin)
615 %% - network (as true, but additionally logs LDAP network traffic)
616 %%
617 %% Defaults to false.
618 %%
619 %% {log, false},
620
621 %%
622 %% Authentication
623 %% ==============
624 %%
625
626 %% Pattern to convert the username given through AMQP to a DN before
627 %% binding
628 %%
629 %% {user_dn_pattern, "cn=${username},ou=People,dc=example,dc=com"},
630
631 %% Alternatively, you can convert a username to a Distinguished
632 %% Name via an LDAP lookup after binding. See the documentation for
633 %% full details.
634
635 %% When converting a username to a dn via a lookup, set these to
636 %% the name of the attribute that represents the user name, and the
637 %% base DN for the lookup query.
638 %%
639 %% {dn_lookup_attribute, "userPrincipalName"},
640 %% {dn_lookup_base, "DC=gopivotal,DC=com"},
641
642 %% Controls how to bind for authorisation queries and also to
643 %% retrieve the details of users logging in without presenting a
644 %% password (e.g., SASL EXTERNAL).
645 %% One of
646 %% - as_user (to bind as the authenticated user - requires a password)
647 %% - anon (to bind anonymously)
648 %% - {UserDN, Password} (to bind with a specified user name and password)
649 %%
650 %% Defaults to 'as_user'.
651 %%
652 %% {other_bind, as_user},
653
654 %%
655 %% Authorisation
656 %% =============
657 %%
658
659 %% The LDAP plugin can perform a variety of queries against your
660 %% LDAP server to determine questions of authorisation. See
661 %% http://www.rabbitmq.com/ldap.html#authorisation for more
662 %% information.
663
664 %% Set the query to use when determining vhost access
665 %%
666 %% {vhost_access_query, {in_group,
667 %% "ou=${vhost}-users,ou=vhosts,dc=example,dc=com"}},
668
669 %% Set the query to use when determining resource (e.g., queue) access
670 %%
671 %% {resource_access_query, {constant, true}},
672
673 %% Set queries to determine which tags a user has
674 %%
675 %% {tag_queries, []}
676 ]}
677].
diff --git a/templates/etc/rabbitmq/rabbitmq.config.j2 b/templates/etc/rabbitmq/rabbitmq.config.j2
new file mode 100644
index 0000000..97ae132
--- /dev/null
+++ b/templates/etc/rabbitmq/rabbitmq.config.j2
@@ -0,0 +1,9 @@
1[
2 {rabbit, [
3{% if rabbitmq_listeners is not defined %}
4 {tcp_listeners, [{{ rabbitmq_listen_port }}]}
5{% elif rabbitmq_listeners is defined %}
6 {tcp_listeners, [{% for item in rabbitmq_listeners %}{"{{ item }}", {{ rabbitmq_listen_port }}}{% if not loop.last %}, {% endif %}{% endfor %}]}
7{% endif %}
8 ]}
9].