diff options
Diffstat (limited to 'tasks/rabbitmq_ha_config.yml')
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 19 |
1 files changed, 13 insertions, 6 deletions
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 }}" |