]> git.immae.eu Git - github/fretlink/ansible-rabbitmq.git/blob - tasks/rabbitmq_ha_config.yml
Merge pull request #18 from gaetanfl/fix_policy_name
[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: rabbitmq_ha_config | install rabbitMQ admin
8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin
9 become: true
10 when: not rabbitmqadmin_check['stat']['exists']
11
12 - name: rabbitmq_ha_config | moving the rabbitMQ Admin
13 shell: mv rabbitmqadmin /usr/sbin
14 become: true
15 when: not rabbitmqadmin_check['stat']['exists']
16
17 - name: rabbitmq_ha_config | making executable rabbitMQ Admin
18 shell: chmod +x /usr/sbin/rabbitmqadmin
19 notify: restart rabbitmq-server
20 become: true
21 when: not rabbitmqadmin_check['stat']['exists']
22
23 - name: rabbitmq_ha_config | creating queue(s)
24 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }}
25 run_once: true
26 become: true
27 when:
28 - item['queue_name'] is defined
29 with_items: "{{ rabbitmq_config }}"
30
31 - name: rabbitmq_ha_config | setting up ha on queue(s)
32 rabbitmq_policy:
33 name: "ha-all{{ policy_name }}"
34 pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
35 vhost: "{{ item.vhost | default('/') }}"
36 tags: "{{ item.tags }}"
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('')) }}"
41 run_once: true
42 become: true
43 when: item.queue_name is defined or item.policy_pattern is defined
44 with_items: "{{ rabbitmq_config }}"
45
46 - name: rabbitmq_ha_config | creating exchange(s)
47 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }}
48 run_once: true
49 become: true
50 with_items: "{{ rabbitmq_config }}"
51 when: item['exchange_name'] is defined
52
53 - name: rabbitmq_ha_config | creating binding(s)
54 command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }}
55 run_once: true
56 become: true
57 with_items: "{{ rabbitmq_config }}"
58 when: item['exchange_name'] is defined