diff options
-rw-r--r-- | defaults/main.yml | 8 | ||||
-rw-r--r-- | tasks/debian.yml | 19 | ||||
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 13 |
3 files changed, 31 insertions, 9 deletions
diff --git a/defaults/main.yml b/defaults/main.yml index 9e9f3c8..4a09ac9 100644 --- a/defaults/main.yml +++ b/defaults/main.yml | |||
@@ -7,6 +7,9 @@ rabbitmq_config: [] | |||
7 | # type: 'direct' | 7 | # type: 'direct' |
8 | # routing_key: 'logstash' | 8 | # routing_key: 'logstash' |
9 | # tags: 'ha-mode=all,ha-sync-mode=automatic' | 9 | # tags: 'ha-mode=all,ha-sync-mode=automatic' |
10 | # - policy_pattern: '.*' | ||
11 | # vhost: 'apps' | ||
12 | # tags: 'ha-mode=all,ha-sync-mode=automatic' | ||
10 | 13 | ||
11 | # Defines if rabbitmq ha should be configured | 14 | # Defines if rabbitmq ha should be configured |
12 | rabbitmq_config_ha: false | 15 | rabbitmq_config_ha: false |
@@ -15,7 +18,12 @@ rabbitmq_config_service: false | |||
15 | rabbitmq_config_file: 'etc/rabbitmq/rabbitmq.config.j2' | 18 | rabbitmq_config_file: 'etc/rabbitmq/rabbitmq.config.j2' |
16 | 19 | ||
17 | rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main' | 20 | rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main' |
21 | #other repos | ||
22 | #rabbitmq_debian_repo: deb https://dl.bintray.com/rabbitmq/debian {{ ansible_distribution_release }} main #bintray | ||
18 | rabbitmq_debian_repo_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc' | 23 | rabbitmq_debian_repo_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc' |
24 | #rabbitmq_debian_repo_key: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq | ||
25 | rabbitmq_debian_erlang_from_rabbit: false | ||
26 | #rabbitmq_debian_version: 3.7.9 # current version if not defined | ||
19 | 27 | ||
20 | # Defines if setting up a rabbitmq cluster | 28 | # Defines if setting up a rabbitmq cluster |
21 | rabbitmq_enable_clustering: false | 29 | rabbitmq_enable_clustering: false |
diff --git a/tasks/debian.yml b/tasks/debian.yml index b25d39b..f35bf55 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml | |||
@@ -9,14 +9,21 @@ | |||
9 | apt_repository: | 9 | apt_repository: |
10 | repo: "{{ rabbitmq_debian_repo }}" | 10 | repo: "{{ rabbitmq_debian_repo }}" |
11 | state: present | 11 | state: present |
12 | register: "rabbitmq_repo_added" | ||
13 | become: true | 12 | become: true |
14 | 13 | ||
15 | - name: debian | updating apt cache | 14 | - name: debian | add Rabbitmq erlang repo key |
16 | apt: | 15 | apt_key: |
17 | update_cache: yes | 16 | url: https://bintray.com/user/downloadSubjectPublicKey?username=rabbitmq-erlang |
17 | state: present | ||
18 | become: true | ||
19 | when: rabbitmq_debian_erlang_from_rabbit | ||
20 | |||
21 | - name: debian | add Rabbitmq erlang repo | ||
22 | apt_repository: | ||
23 | repo: deb https://dl.bintray.com/rabbitmq-erlang/debian {{ ansible_distribution_release }} erlang | ||
24 | state: present | ||
18 | become: true | 25 | become: true |
19 | when: rabbitmq_repo_added.changed | 26 | when: rabbitmq_debian_erlang_from_rabbit |
20 | 27 | ||
21 | - name: debian | installing RabbitMQ server | 28 | - name: debian | installing RabbitMQ server |
22 | apt: | 29 | apt: |
@@ -24,7 +31,7 @@ | |||
24 | state: present | 31 | state: present |
25 | become: true | 32 | become: true |
26 | with_items: | 33 | with_items: |
27 | - rabbitmq-server | 34 | - rabbitmq-server{{ (rabbitmq_debian_version is defined) | ternary(['=',rabbitmq_debian_version] | join(''),'')}} |
28 | 35 | ||
29 | - name: debian | enabling the RabbitMQ Management Console | 36 | - name: debian | enabling the RabbitMQ Management Console |
30 | rabbitmq_plugin: | 37 | rabbitmq_plugin: |
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index ffda6e9..9ebe297 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml | |||
@@ -24,16 +24,23 @@ | |||
24 | command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }} | 24 | command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }} --vhost={{ item['vhost'] | default('/') }} |
25 | run_once: true | 25 | run_once: true |
26 | become: true | 26 | become: true |
27 | when: | ||
28 | - item['queue_name'] is defined | ||
27 | with_items: "{{ rabbitmq_config }}" | 29 | with_items: "{{ rabbitmq_config }}" |
28 | 30 | ||
29 | - name: rabbitmq_ha_config | setting up ha on queue(s) | 31 | - name: rabbitmq_ha_config | setting up ha on queue(s) |
30 | rabbitmq_policy: | 32 | rabbitmq_policy: |
31 | name: "ha-all" | 33 | name: "ha-all{{ policy_name }}" |
32 | pattern: "{{ item['queue_name'] }}" | 34 | pattern: "{{ item.queue_name | default(item.policy_pattern) }}" |
33 | tags: "{{ item['tags'] }}" | 35 | vhost: "{{ item.vhost | default('/') }}" |
36 | tags: "{{ item.tags }}" | ||
34 | state: present | 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('')) }}" | ||
35 | run_once: true | 41 | run_once: true |
36 | become: true | 42 | become: true |
43 | when: item.queue_name is defined or item.policy_pattern is defined | ||
37 | with_items: "{{ rabbitmq_config }}" | 44 | with_items: "{{ rabbitmq_config }}" |
38 | 45 | ||
39 | - name: rabbitmq_ha_config | creating exchange(s) | 46 | - name: rabbitmq_ha_config | creating exchange(s) |