]> git.immae.eu Git - github/fretlink/ansible-rabbitmq.git/commitdiff
Allow multiple policies creation 1/head
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Tue, 18 Dec 2018 10:36:00 +0000 (11:36 +0100)
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Tue, 18 Dec 2018 10:36:00 +0000 (11:36 +0100)
defaults/main.yml
tasks/rabbitmq_ha_config.yml

index 9e9f3c85f1e09a8f58c2cfef5c75966ed82f6084..41161c8d0f61c65d68242969d3babc238735b793 100644 (file)
@@ -7,6 +7,9 @@ rabbitmq_config: []
   #   type: 'direct'
   #   routing_key: 'logstash'
   #   tags: 'ha-mode=all,ha-sync-mode=automatic'
+  # - policy_pattern: '.*'
+  #   vhost: 'apps'
+  #   tags: 'ha-mode=all,ha-sync-mode=automatic'
 
 # Defines if rabbitmq ha should be configured
 rabbitmq_config_ha: false
index bf74957c06f5f8dea618b33aa000b48e63f299fd..e62fc83301cbcbf038cc0a4af85836da2de5db69 100644 (file)
   command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }}
   run_once: true
   become: true
+  when:
+    - item['queue_name'] is defined
   with_items: "{{ rabbitmq_config }}"
 
 - name: rabbitmq_ha_config | setting up ha on queue(s)
   rabbitmq_policy:
-    name: "ha-all"
-    pattern: "{{ item['queue_name'] }}"
-    tags: "{{ item['tags'] }}"
+    name: "ha-all{{ policy_name }}"
+    pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
+    vhost: "{{ item.vhost | default('/') }}"
+    tags: "{{ item.tags }}"
     state: present
+  vars:
+    policy_vhost: "{{ item.vhost | default('/') }}"
+    policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}"
   run_once: true
   become: true
+  when: item.queue_name is defined or item.policy_pattern is defined
   with_items: "{{ rabbitmq_config }}"
 
 - name: rabbitmq_ha_config | creating exchange(s)