]>
Commit | Line | Data |
---|---|---|
109c6b75 LSJ |
1 | --- |
2 | - name: rabbitmq_ha_config | checking if rabbitmqadmin is installed | |
3 | stat: | |
4 | path: /usr/sbin/rabbitmqadmin | |
5 | register: rabbitmqadmin_check | |
6 | ||
4353d29a LSJ |
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 | |
a67dde50 | 12 | become: true |
4353d29a | 13 | notify: restart rabbitmq-server |
a67dde50 | 14 | when: not rabbitmqadmin_check['stat']['exists'] |
109c6b75 | 15 | |
109c6b75 | 16 | - name: rabbitmq_ha_config | creating queue(s) |
ebb0d317 | 17 | command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }} |
109c6b75 | 18 | run_once: true |
a67dde50 | 19 | become: true |
c3b85a38 GD |
20 | when: |
21 | - item['queue_name'] is defined | |
109c6b75 LSJ |
22 | with_items: "{{ rabbitmq_config }}" |
23 | ||
24 | - name: rabbitmq_ha_config | setting up ha on queue(s) | |
25 | rabbitmq_policy: | |
c3b85a38 GD |
26 | name: "ha-all{{ policy_name }}" |
27 | pattern: "{{ item.queue_name | default(item.policy_pattern) }}" | |
28 | vhost: "{{ item.vhost | default('/') }}" | |
29 | tags: "{{ item.tags }}" | |
109c6b75 | 30 | state: present |
c3b85a38 GD |
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('')) }}" | |
109c6b75 | 34 | run_once: true |
a67dde50 | 35 | become: true |
c3b85a38 | 36 | when: item.queue_name is defined or item.policy_pattern is defined |
109c6b75 LSJ |
37 | with_items: "{{ rabbitmq_config }}" |
38 | ||
39 | - name: rabbitmq_ha_config | creating exchange(s) | |
ebb0d317 | 40 | command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }} --vhost={{ item['vhost'] | default('/') }} |
109c6b75 | 41 | run_once: true |
a67dde50 | 42 | become: true |
109c6b75 | 43 | with_items: "{{ rabbitmq_config }}" |
a67dde50 | 44 | when: item['exchange_name'] is defined |
109c6b75 LSJ |
45 | |
46 | - name: rabbitmq_ha_config | creating binding(s) | |
ebb0d317 | 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('/') }} |
109c6b75 | 48 | run_once: true |
a67dde50 | 49 | become: true |
109c6b75 | 50 | with_items: "{{ rabbitmq_config }}" |
a67dde50 | 51 | when: item['exchange_name'] is defined |