blob: e62fc83301cbcbf038cc0a4af85836da2de5db69 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
---
- name: rabbitmq_ha_config | checking if rabbitmqadmin is installed
stat:
path: /usr/sbin/rabbitmqadmin
register: rabbitmqadmin_check
- name: rabbitmq_ha_config | install rabbitMQ admin
shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin
become: true
when: not rabbitmqadmin_check['stat']['exists']
- name: rabbitmq_ha_config | moving the rabbitMQ Admin
shell: mv rabbitmqadmin /usr/sbin
become: true
when: not rabbitmqadmin_check['stat']['exists']
- name: rabbitmq_ha_config | making executable rabbitMQ Admin
shell: chmod +x /usr/sbin/rabbitmqadmin
notify: restart rabbitmq-server
become: true
when: not rabbitmqadmin_check['stat']['exists']
- name: rabbitmq_ha_config | creating queue(s)
command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }}
run_once: true
become: true
when:
- item['queue_name'] is defined
with_items: "{{ rabbitmq_config }}"
- name: rabbitmq_ha_config | setting up ha on queue(s)
rabbitmq_policy:
name: "ha-all{{ policy_name }}"
pattern: "{{ item.queue_name | default(item.policy_pattern) }}"
vhost: "{{ item.vhost | default('/') }}"
tags: "{{ item.tags }}"
state: present
vars:
policy_vhost: "{{ item.vhost | default('/') }}"
policy_name: "{{ item.policy_pattern is defined | ternary(policy_vhost + item.policy_pattern|default(''),item.queue_name|default('')) }}"
run_once: true
become: true
when: item.queue_name is defined or item.policy_pattern is defined
with_items: "{{ rabbitmq_config }}"
- name: rabbitmq_ha_config | creating exchange(s)
command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }}
run_once: true
become: true
with_items: "{{ rabbitmq_config }}"
when: item['exchange_name'] is defined
- name: rabbitmq_ha_config | creating binding(s)
command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }}
run_once: true
become: true
with_items: "{{ rabbitmq_config }}"
when: item['exchange_name'] is defined
|