diff options
Diffstat (limited to 'tasks/rabbitmq_ha_config.yml')
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml new file mode 100644 index 0000000..8811b6d --- /dev/null +++ b/tasks/rabbitmq_ha_config.yml | |||
@@ -0,0 +1,44 @@ | |||
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: rabbitmq_ha_config | install rabbitMQ admin | ||
8 | shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin | ||
9 | when: not rabbitmqadmin_check.stat.exists | ||
10 | |||
11 | - name: rabbitmq_ha_config | moving the rabbitMQ Admin | ||
12 | shell: mv rabbitmqadmin /usr/sbin | ||
13 | when: not rabbitmqadmin_check.stat.exists | ||
14 | |||
15 | - name: rabbitmq_ha_config | making executable rabbitMQ Admin | ||
16 | shell: chmod +x /usr/sbin/rabbitmqadmin | ||
17 | notify: restart rabbitmq-server | ||
18 | when: not rabbitmqadmin_check.stat.exists | ||
19 | |||
20 | - name: rabbitmq_ha_config | creating queue(s) | ||
21 | command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }} | ||
22 | run_once: true | ||
23 | with_items: "{{ rabbitmq_config }}" | ||
24 | |||
25 | - name: rabbitmq_ha_config | setting up ha on queue(s) | ||
26 | rabbitmq_policy: | ||
27 | name: "ha-all" | ||
28 | pattern: "{{ item.queue_name }}" | ||
29 | tags: "{{ item.tags }}" | ||
30 | state: present | ||
31 | run_once: true | ||
32 | with_items: "{{ rabbitmq_config }}" | ||
33 | |||
34 | - name: rabbitmq_ha_config | creating exchange(s) | ||
35 | command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} | ||
36 | run_once: true | ||
37 | with_items: "{{ rabbitmq_config }}" | ||
38 | when: item.exchange_name is defined | ||
39 | |||
40 | - name: rabbitmq_ha_config | creating binding(s) | ||
41 | command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }} | ||
42 | run_once: true | ||
43 | with_items: "{{ rabbitmq_config }}" | ||
44 | when: item.exchange_name is defined | ||