aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2018-12-18 11:36:00 +0100
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>2018-12-18 11:36:00 +0100
commitc3b85a38ba6ce9465ee67c571916c5be11f683f0 (patch)
tree5bb38ff6dd0ac6cc1f5d363c48365f30d26fcf1c
parent991fe83812bb2814096e8ec3e8f6dc86fee5f3ef (diff)
downloadansible-rabbitmq-c3b85a38ba6ce9465ee67c571916c5be11f683f0.tar.gz
ansible-rabbitmq-c3b85a38ba6ce9465ee67c571916c5be11f683f0.tar.zst
ansible-rabbitmq-c3b85a38ba6ce9465ee67c571916c5be11f683f0.zip
Allow multiple policies creation
-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 9e9f3c8..41161c8 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)