2 - name: rabbitmq_ha_config | checking if rabbitmqadmin is installed
4 path: /usr/sbin/rabbitmqadmin
5 register: rabbitmqadmin_check
7 - name: rabbitmq_ha_config | install rabbitMQ admin
8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin
10 when: not rabbitmqadmin_check['stat']['exists']
12 - name: rabbitmq_ha_config | moving the rabbitMQ Admin
13 shell: mv rabbitmqadmin /usr/sbin
15 when: not rabbitmqadmin_check['stat']['exists']
17 - name: rabbitmq_ha_config | making executable rabbitMQ Admin
18 shell: chmod +x /usr/sbin/rabbitmqadmin
19 notify: restart rabbitmq-server
21 when: not rabbitmqadmin_check['stat']['exists']
23 - name: rabbitmq_ha_config | creating queue(s)
24 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }}
28 - item['queue_name'] is defined
29 with_items: "{{ rabbitmq_config }}"
31 - name: rabbitmq_ha_config | setting up ha on queue(s)
33 name: "ha-all{{ policy_name }}"
34 pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
35 vhost: "{{ item.vhost | default('/') }}"
36 tags: "{{ item.tags }}"
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('')) }}"
43 when: item.queue_name is defined or item.policy_pattern is defined
44 with_items: "{{ rabbitmq_config }}"
46 - name: rabbitmq_ha_config | creating exchange(s)
47 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }}
50 with_items: "{{ rabbitmq_config }}"
51 when: item['exchange_name'] is defined
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'] }} --vhost={{ item['vhost'] | default('/') }}
57 with_items: "{{ rabbitmq_config }}"
58 when: item['exchange_name'] is defined