]> git.immae.eu Git - github/fretlink/ansible-rabbitmq.git/blob - tasks/rabbitmq_ha_config.yml
Add partition handling setting
[github/fretlink/ansible-rabbitmq.git] / tasks / rabbitmq_ha_config.yml
1 ---
2 - name: rabbitmq_ha_config | checking if rabbitmqadmin is installed
3 stat:
4 path: /usr/sbin/rabbitmqadmin
5 register: rabbitmqadmin_check
6
7 - name: rabbit_ha_config | Installing rabbitMQ admin
8 get_url:
9 url: http://guest:guest@localhost:15672/cli/rabbitmqadmin
10 dest: /usr/sbin/rabbitmqadmin
11 mode: u=rwx,g=rw,o=rw
12 become: true
13 notify: restart rabbitmq-server
14 when: not rabbitmqadmin_check['stat']['exists']
15
16 - name: rabbitmq_ha_config | creating exchange(s)
17 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }}
18 run_once: true
19 delegate_to: "{{ rabbitmq_master }}"
20 become: true
21 with_items: "{{ rabbitmq_config }}"
22 when: item['exchange_name'] is defined
23
24 - name: rabbitmq_ha_config | creating queue(s)
25 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }}
26 run_once: true
27 delegate_to: "{{ rabbitmq_master }}"
28 become: true
29 when:
30 - item['queue_name'] is defined
31 with_items: "{{ rabbitmq_config }}"
32
33 - name: rabbitmq_ha_config | setting up ha on queue(s)
34 rabbitmq_policy:
35 name: "ha-all{{ policy_name }}"
36 pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
37 vhost: "{{ item.vhost | default('/') }}"
38 tags: "{{ item.tags }}"
39 state: present
40 vars:
41 policy_vhost: "{{ item.vhost | default('/') }}"
42 policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}"
43 run_once: true
44 delegate_to: "{{ rabbitmq_master }}"
45 become: true
46 when: item.queue_name is defined or item.policy_pattern is defined
47 with_items: "{{ rabbitmq_config }}"
48
49 - name: rabbitmq_ha_config | creating binding(s)
50 command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }} --vhost={{ item['vhost'] | default('/') }}
51 run_once: true
52 delegate_to: "{{ rabbitmq_master }}"
53 become: true
54 with_items: "{{ rabbitmq_config }}"
55 when: item['exchange_name'] is defined