aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--defaults/main.yml38
-rw-r--r--tasks/main.yml1
-rw-r--r--tasks/rabbitmq_ha_config.yml19
3 files changed, 36 insertions, 22 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index ff7d922..f3d2c20 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -1,12 +1,15 @@
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"
10# - policy_pattern: ".*"
11# vhost: apps
12# tags: "ha-mode=all,ha-sync-mode=automatic"
10 13
11# Defines if rabbitmq ha should be configured 14# Defines if rabbitmq ha should be configured
12rabbitmq_config_ha: false 15rabbitmq_config_ha: false
@@ -20,7 +23,9 @@ rabbitmq_debian_repo: "deb https://dl.bintray.com/rabbitmq/debian {{ ansible_dis
20# rabbitmq_debian_repo_key: https://www.rabbitmq.com/rabbitmq-release-signing-key.asc 23# rabbitmq_debian_repo_key: https://www.rabbitmq.com/rabbitmq-release-signing-key.asc
21rabbitmq_debian_repo_key: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq 24rabbitmq_debian_repo_key: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq
22rabbitmq_debian_erlang_from_rabbit: false 25rabbitmq_debian_erlang_from_rabbit: false
23rabbitmq_debian_version: 3.7.9 # current version if not defined 26
27# current version if not defined
28rabbitmq_debian_version: 3.7.9
24 29
25# Defines if setting up a rabbitmq cluster 30# Defines if setting up a rabbitmq cluster
26rabbitmq_enable_clustering: false 31rabbitmq_enable_clustering: false
@@ -29,20 +34,21 @@ rabbitmq_erlang_cookie_file: /var/lib/rabbitmq/.erlang.cookie
29 34
30rabbitmq_listen_port: 5672 35rabbitmq_listen_port: 5672
31rabbitmq_listeners: [] 36rabbitmq_listeners: []
32 # - 127.0.0.1 37# - 127.0.0.1
33 # - '::1' 38# - '::1'
34 39
35rabbitmq_ssl_enable: false 40rabbitmq_ssl_enable: false
36rabbitmq_ssl_port: 5671 41rabbitmq_ssl_port: 5671
37rabbitmq_ssl_listeners: [] 42rabbitmq_ssl_listeners: []
38 # - '127.0.0.1' 43# - 127.0.0.1
39 # - '::1' 44# - "::1"
45
40rabitmq_ssl_options: {} 46rabitmq_ssl_options: {}
41 # cacertfile: '"/path/to/testca/cacert.pem"' 47# cacertfile: '"/path/to/testca/cacert.pem"'
42 # certfile: '"/path/to/server/cert.pem"' 48# certfile: '"/path/to/server/cert.pem"'
43 # keyfile: '"/path/to/server/key.pem"' 49# keyfile: '"/path/to/server/key.pem"'
44 # verify: verify_peer 50# verify: verify_peer
45 # fail_if_no_peer_cert: "false" 51# fail_if_no_peer_cert: "false"
46 52
47# Defines the inventory host that should be considered master 53# Defines the inventory host that should be considered master
48rabbitmq_master: [] 54rabbitmq_master: []
diff --git a/tasks/main.yml b/tasks/main.yml
index 3205473..1ef08f0 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,3 +1,4 @@
1---
1# tasks file for ansible-rabbitmq 2# tasks file for ansible-rabbitmq
2- include: debian.yml 3- include: debian.yml
3 when: ansible_os_family == "Debian" 4 when: ansible_os_family == "Debian"
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
index 0048b0c..cea301c 100644
--- a/tasks/rabbitmq_ha_config.yml
+++ b/tasks/rabbitmq_ha_config.yml
@@ -14,30 +14,37 @@
14 when: not rabbitmqadmin_check['stat']['exists'] 14 when: not rabbitmqadmin_check['stat']['exists']
15 15
16- name: rabbitmq_ha_config | creating queue(s) 16- name: rabbitmq_ha_config | creating queue(s)
17 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} 17 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }}
18 run_once: true 18 run_once: true
19 become: true 19 become: true
20 when:
21 - item['queue_name'] is defined
20 with_items: "{{ rabbitmq_config }}" 22 with_items: "{{ rabbitmq_config }}"
21 23
22- name: rabbitmq_ha_config | setting up ha on queue(s) 24- name: rabbitmq_ha_config | setting up ha on queue(s)
23 rabbitmq_policy: 25 rabbitmq_policy:
24 name: ha-all 26 name: "ha-all{{ policy_name }}"
25 pattern: "{{ item['queue_name'] }}" 27 pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
26 tags: "{{ item['tags'] }}" 28 vhost: "{{ item.vhost | default('/') }}"
29 tags: "{{ item.tags }}"
27 state: present 30 state: present
31 vars:
32 policy_vhost: "{{ item.vhost | default('/') }}"
33 policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}"
28 run_once: true 34 run_once: true
29 become: true 35 become: true
36 when: item.queue_name is defined or item.policy_pattern is defined
30 with_items: "{{ rabbitmq_config }}" 37 with_items: "{{ rabbitmq_config }}"
31 38
32- name: rabbitmq_ha_config | creating exchange(s) 39- name: rabbitmq_ha_config | creating exchange(s)
33 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} 40 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }}
34 run_once: true 41 run_once: true
35 become: true 42 become: true
36 with_items: "{{ rabbitmq_config }}" 43 with_items: "{{ rabbitmq_config }}"
37 when: item['exchange_name'] is defined 44 when: item['exchange_name'] is defined
38 45
39- name: rabbitmq_ha_config | creating binding(s) 46- name: rabbitmq_ha_config | creating binding(s)
40 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'] }} --vhost={{ item['vhost'] | default('/') }}
41 run_once: true 48 run_once: true
42 become: true 49 become: true
43 with_items: "{{ rabbitmq_config }}" 50 with_items: "{{ rabbitmq_config }}"