aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2018-12-20 00:52:51 -0500
committerGitHub <noreply@github.com>2018-12-20 00:52:51 -0500
commit2cf614d413be9c9f4948e034b6ec421a5964c00a (patch)
treeecc5e49a989b2e826d9632af2d009df2346f6e80
parent80121e2128f9b9702fbcb2c1fe713a0d42212c90 (diff)
parentc3b85a38ba6ce9465ee67c571916c5be11f683f0 (diff)
downloadansible-rabbitmq-2cf614d413be9c9f4948e034b6ec421a5964c00a.tar.gz
ansible-rabbitmq-2cf614d413be9c9f4948e034b6ec421a5964c00a.tar.zst
ansible-rabbitmq-2cf614d413be9c9f4948e034b6ec421a5964c00a.zip
Merge pull request #18 from gaetanfl/fix_policy_name
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 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)