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