diff options
author | Larry Smith Jr <mrlesmithjr@gmail.com> | 2015-11-13 02:56:48 -0500 |
---|---|---|
committer | Larry Smith Jr <mrlesmithjr@gmail.com> | 2015-11-13 02:56:48 -0500 |
commit | 93a297c59940c7cfe88afe0f9110af5b4be521e3 (patch) | |
tree | 1d3f3904ecb83138f557f9a3ed40e72e032a3bfc /tasks | |
parent | 93f90e27f24275f9ccca908a2d77543dfa9bb379 (diff) | |
download | ansible-rabbitmq-93a297c59940c7cfe88afe0f9110af5b4be521e3.tar.gz ansible-rabbitmq-93a297c59940c7cfe88afe0f9110af5b4be521e3.tar.zst ansible-rabbitmq-93a297c59940c7cfe88afe0f9110af5b4be521e3.zip |
updated tasks, fixed broken HA configuration tasks
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/debian.yml | 21 | ||||
-rw-r--r-- | tasks/main.yml | 2 | ||||
-rw-r--r-- | tasks/rabbitmq_clustering.yml | 24 | ||||
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 18 | ||||
-rw-r--r-- | tasks/rabbitmq_users.yml | 27 |
5 files changed, 80 insertions, 12 deletions
diff --git a/tasks/debian.yml b/tasks/debian.yml index 4b38782..12ddd3b 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml | |||
@@ -1,18 +1,29 @@ | |||
1 | --- | 1 | --- |
2 | - name: debian | adding RabbitMQ public GPG key to the apt repo | 2 | - name: debian | adding RabbitMQ public GPG key to the apt repo |
3 | apt_key: url=http://www.rabbitmq.com/rabbitmq-signing-key-public.asc state=present | 3 | apt_key: |
4 | url: "{{ rabbitmq_debian_repo_key }}" | ||
5 | state: present | ||
4 | 6 | ||
5 | - name: debian | adding RabbitMQ repo | 7 | - name: debian | adding RabbitMQ repo |
6 | apt_repository: repo='deb http://www.rabbitmq.com/debian/ testing main' update_cache=no state=present | 8 | apt_repository: |
9 | repo: "{{ rabbitmq_debian_repo }}" | ||
10 | state: present | ||
7 | 11 | ||
8 | - name: debian | installing RabbitMQ server | 12 | - name: debian | installing RabbitMQ server |
9 | apt: name={{ item }} state=present | 13 | apt: |
14 | name: "{{ item }}" | ||
15 | state: present | ||
10 | with_items: | 16 | with_items: |
11 | - rabbitmq-server | 17 | - rabbitmq-server |
12 | 18 | ||
13 | - name: debian | enabling the RabbitMQ Management Console | 19 | - name: debian | enabling the RabbitMQ Management Console |
14 | rabbitmq_plugin: names=rabbitmq_management state=enabled | 20 | rabbitmq_plugin: |
21 | names: rabbitmq_management | ||
22 | state: enabled | ||
15 | notify: restart rabbitmq-server | 23 | notify: restart rabbitmq-server |
16 | 24 | ||
17 | - name: debian | ensuring that the RabbitMQ service is running | 25 | - name: debian | ensuring that the RabbitMQ service is running |
18 | service: name=rabbitmq-server state=started enabled=yes | 26 | service: |
27 | name: rabbitmq-server | ||
28 | state: started | ||
29 | enabled: yes | ||
diff --git a/tasks/main.yml b/tasks/main.yml index cd24ad2..bde00da 100644 --- a/tasks/main.yml +++ b/tasks/main.yml | |||
@@ -11,3 +11,5 @@ | |||
11 | 11 | ||
12 | - include: rabbitmq_ha_config.yml | 12 | - include: rabbitmq_ha_config.yml |
13 | when: config_rabbitmq_ha and enable_rabbitmq_clustering | 13 | when: config_rabbitmq_ha and enable_rabbitmq_clustering |
14 | |||
15 | - include: rabbitmq_users.yml | ||
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml index 348662a..f9b5157 100644 --- a/tasks/rabbitmq_clustering.yml +++ b/tasks/rabbitmq_clustering.yml | |||
@@ -6,7 +6,9 @@ | |||
6 | command: rabbitmqctl reset | 6 | command: rabbitmqctl reset |
7 | 7 | ||
8 | - name: rabbitmq_clustering | stopping rabbitmq-server | 8 | - name: rabbitmq_clustering | stopping rabbitmq-server |
9 | service: name=rabbitmq-server state=stopped | 9 | service: |
10 | name: rabbitmq-server | ||
11 | state: stopped | ||
10 | 12 | ||
11 | #- name: grabbing erlang cookie | 13 | #- name: grabbing erlang cookie |
12 | # shell: cat /var/lib/rabbitmq/.erlang.cookie | 14 | # shell: cat /var/lib/rabbitmq/.erlang.cookie |
@@ -14,11 +16,19 @@ | |||
14 | # when: inventory_hostname == "{{ rabbitmq_master }}" | 16 | # when: inventory_hostname == "{{ rabbitmq_master }}" |
15 | 17 | ||
16 | - name: rabbitmq_clustering | copy erlang cookie | 18 | - name: rabbitmq_clustering | copy erlang cookie |
17 | template: src=erlang.cookie.j2 dest={{ erlang_cookie_file }} owner=rabbitmq group=rabbitmq mode=0400 backup=yes | 19 | template: |
20 | src: erlang.cookie.j2 | ||
21 | dest: "{{ erlang_cookie_file }}" | ||
22 | owner: rabbitmq | ||
23 | group: rabbitmq | ||
24 | mode: 0400 | ||
25 | backup: yes #backing up in case the need to recover | ||
18 | # when: inventory_hostname != "{{ rabbitmq_master }}" | 26 | # when: inventory_hostname != "{{ rabbitmq_master }}" |
19 | 27 | ||
20 | - name: rabbitmq_clustering | restarting rabbitmq-server on master | 28 | - name: rabbitmq_clustering | restarting rabbitmq-server on master |
21 | service: name=rabbitmq-server state=restarted | 29 | service: |
30 | name: rabbitmq-server | ||
31 | state: restarted | ||
22 | when: inventory_hostname == "{{ rabbitmq_master }}" | 32 | when: inventory_hostname == "{{ rabbitmq_master }}" |
23 | 33 | ||
24 | - name: rabbitmq_clustering | starting rabbitmq app on master | 34 | - name: rabbitmq_clustering | starting rabbitmq app on master |
@@ -31,7 +41,9 @@ | |||
31 | when: inventory_hostname != "{{ rabbitmq_master }}" | 41 | when: inventory_hostname != "{{ rabbitmq_master }}" |
32 | 42 | ||
33 | - name: rabbitmq_clustering | restarting rabbitmq-server | 43 | - name: rabbitmq_clustering | restarting rabbitmq-server |
34 | service: name=rabbitmq-server state=restarted | 44 | service: |
45 | name: rabbitmq-server | ||
46 | state: restarted | ||
35 | when: inventory_hostname != "{{ rabbitmq_master }}" | 47 | when: inventory_hostname != "{{ rabbitmq_master }}" |
36 | 48 | ||
37 | - name: rabbitmq_clustering | stopping rabbitmq app | 49 | - name: rabbitmq_clustering | stopping rabbitmq app |
@@ -52,5 +64,7 @@ | |||
52 | when: inventory_hostname != "{{ rabbitmq_master }}" | 64 | when: inventory_hostname != "{{ rabbitmq_master }}" |
53 | 65 | ||
54 | - name: rabbitmq_clustering | marking as clustered | 66 | - name: rabbitmq_clustering | marking as clustered |
55 | file: path=/etc/rabbitmq/clustered state=touch | 67 | file: |
68 | path: /etc/rabbitmq/clustered | ||
69 | state: touch | ||
56 | when: cluster_master.changed or cluster_joined.changed | 70 | when: cluster_master.changed or cluster_joined.changed |
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index c048aed..3cbc382 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml | |||
@@ -1,13 +1,21 @@ | |||
1 | --- | 1 | --- |
2 | - name: rabbitmq_ha_config | checking if rabbitmqadmin is installed | ||
3 | stat: | ||
4 | path: /usr/sbin/rabbitmqadmin | ||
5 | register: rabbitmqadmin_check | ||
6 | |||
2 | - name: rabbitmq_ha_config | install rabbitMQ admin | 7 | - name: rabbitmq_ha_config | install rabbitMQ admin |
3 | shell: wget http://guest:guest@localhost:55672/cli/rabbitmqadmin | 8 | shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin |
9 | when: not rabbitmqadmin_check.stat.exists | ||
4 | 10 | ||
5 | - name: rabbitmq_ha_config | moving the rabbitMQ Admin | 11 | - name: rabbitmq_ha_config | moving the rabbitMQ Admin |
6 | shell: mv rabbitmqadmin /usr/sbin | 12 | shell: mv rabbitmqadmin /usr/sbin |
13 | when: not rabbitmqadmin_check.stat.exists | ||
7 | 14 | ||
8 | - name: rabbitmq_ha_config | making executable rabbitMQ Admin | 15 | - name: rabbitmq_ha_config | making executable rabbitMQ Admin |
9 | shell: chmod +x /usr/sbin/rabbitmqadmin | 16 | shell: chmod +x /usr/sbin/rabbitmqadmin |
10 | notify: restart rabbitmq-server | 17 | notify: restart rabbitmq-server |
18 | when: not rabbitmqadmin_check.stat.exists | ||
11 | 19 | ||
12 | - name: rabbitmq_ha_config | creating queue(s) | 20 | - name: rabbitmq_ha_config | creating queue(s) |
13 | command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }} | 21 | command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }} |
@@ -15,7 +23,11 @@ | |||
15 | with_items: rabbitmq_config | 23 | with_items: rabbitmq_config |
16 | 24 | ||
17 | - name: rabbitmq_ha_config | setting up ha on queue(s) | 25 | - name: rabbitmq_ha_config | setting up ha on queue(s) |
18 | rabbitmq_policy: name='ha-all' pattern='{{ item.queue_name }}' tags="{{ item.tags }}" state=present | 26 | rabbitmq_policy: |
27 | name: "ha-all" | ||
28 | pattern: "{{ item.queue_name }}" | ||
29 | tags: "{{ item.tags }}" | ||
30 | state: present | ||
19 | run_once: true | 31 | run_once: true |
20 | with_items: rabbitmq_config | 32 | with_items: rabbitmq_config |
21 | 33 | ||
@@ -23,8 +35,10 @@ | |||
23 | command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} | 35 | command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} |
24 | run_once: true | 36 | run_once: true |
25 | with_items: rabbitmq_config | 37 | with_items: rabbitmq_config |
38 | when: item.exchange_name is defined | ||
26 | 39 | ||
27 | - name: rabbitmq_ha_config | creating binding(s) | 40 | - name: rabbitmq_ha_config | creating binding(s) |
28 | command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }} | 41 | command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }} |
29 | run_once: true | 42 | run_once: true |
30 | with_items: rabbitmq_config | 43 | with_items: rabbitmq_config |
44 | when: item.exchange_name is defined | ||
diff --git a/tasks/rabbitmq_users.yml b/tasks/rabbitmq_users.yml new file mode 100644 index 0000000..e14d390 --- /dev/null +++ b/tasks/rabbitmq_users.yml | |||
@@ -0,0 +1,27 @@ | |||
1 | --- | ||
2 | - name: rabbitmq_users | creating rabbitmq users | ||
3 | rabbitmq_user: | ||
4 | name: "{{ item.name }}" | ||
5 | password: "{{ item.password }}" | ||
6 | vhost: "{{ item.vhost }}" | ||
7 | configure_priv: "{{ item.configure_priv }}" | ||
8 | read_priv: "{{ item.read_priv }}" | ||
9 | write_priv: "{{ item.write_priv }}" | ||
10 | tags: "{{ item.tags }}" | ||
11 | state: present | ||
12 | with_items: rabbitmq_users | ||
13 | when: (enable_rabbitmq_clustering is defined and not enable_rabbitmq_clustering) or enable_rabbitmq_clustering is not defined | ||
14 | |||
15 | - name: rabbitmq_users | creating rabbitmq users | ||
16 | rabbitmq_user: | ||
17 | name: "{{ item.name }}" | ||
18 | password: "{{ item.password }}" | ||
19 | vhost: "{{ item.vhost }}" | ||
20 | configure_priv: "{{ item.configure_priv }}" | ||
21 | read_priv: "{{ item.read_priv }}" | ||
22 | write_priv: "{{ item.write_priv }}" | ||
23 | tags: "{{ item.tags }}" | ||
24 | state: present | ||
25 | run_once: yes | ||
26 | with_items: rabbitmq_users | ||
27 | when: (enable_rabbitmq_clustering is defined and enable_rabbitmq_clustering) | ||