aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--defaults/main.yml3
-rw-r--r--tasks/rabbitmq_ha_config.yml13
2 files changed, 13 insertions, 3 deletions
diff --git a/defaults/main.yml b/defaults/main.yml
index aeeda6d..4a09ac9 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -7,6 +7,9 @@ rabbitmq_config: []
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
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
index bf74957..e62fc83 100644
--- a/tasks/rabbitmq_ha_config.yml
+++ b/tasks/rabbitmq_ha_config.yml
@@ -24,16 +24,23 @@
24 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 }}
25 run_once: true 25 run_once: true
26 become: true 26 become: true
27 when:
28 - item['queue_name'] is defined
27 with_items: "{{ rabbitmq_config }}" 29 with_items: "{{ rabbitmq_config }}"
28 30
29- name: rabbitmq_ha_config | setting up ha on queue(s) 31- name: rabbitmq_ha_config | setting up ha on queue(s)
30 rabbitmq_policy: 32 rabbitmq_policy:
31 name: "ha-all" 33 name: "ha-all{{ policy_name }}"
32 pattern: "{{ item['queue_name'] }}" 34 pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
33 tags: "{{ item['tags'] }}" 35 vhost: "{{ item.vhost | default('/') }}"
36 tags: "{{ item.tags }}"
34 state: present 37 state: present
38 vars:
39 policy_vhost: "{{ item.vhost | default('/') }}"
40 policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}"
35 run_once: true 41 run_once: true
36 become: true 42 become: true
43 when: item.queue_name is defined or item.policy_pattern is defined
37 with_items: "{{ rabbitmq_config }}" 44 with_items: "{{ rabbitmq_config }}"
38 45
39- name: rabbitmq_ha_config | creating exchange(s) 46- name: rabbitmq_ha_config | creating exchange(s)