diff options
author | Larry Smith Jr <larry.e.smith.jr@gmail.com> | 2015-08-06 20:57:38 -0400 |
---|---|---|
committer | Larry Smith Jr <larry.e.smith.jr@gmail.com> | 2015-08-06 20:57:38 -0400 |
commit | a290f6cfbff072c146c0873160672baf9059390a (patch) | |
tree | 98d4e3ccd04557c61d142527176834622d8dced6 /tasks | |
parent | a06e4a79a5331952ad31c737fbd3d7d82eaa6eb5 (diff) | |
download | ansible-rabbitmq-a290f6cfbff072c146c0873160672baf9059390a.tar.gz ansible-rabbitmq-a290f6cfbff072c146c0873160672baf9059390a.tar.zst ansible-rabbitmq-a290f6cfbff072c146c0873160672baf9059390a.zip |
updated all tasks, cleaned up formatting
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/debian.yml | 16 | ||||
-rw-r--r-- | tasks/main.yml | 6 | ||||
-rw-r--r-- | tasks/rabbitmq_clustering.yml | 38 | ||||
-rw-r--r-- | tasks/rabbitmq_ha_config.yml | 14 |
4 files changed, 38 insertions, 36 deletions
diff --git a/tasks/debian.yml b/tasks/debian.yml index 563563a..4b38782 100644 --- a/tasks/debian.yml +++ b/tasks/debian.yml | |||
@@ -1,22 +1,18 @@ | |||
1 | --- | 1 | --- |
2 | - name: Add the 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: url=http://www.rabbitmq.com/rabbitmq-signing-key-public.asc state=present |
4 | 4 | ||
5 | - name: Add RabbitMQ to the sources list | 5 | - name: debian | adding RabbitMQ repo |
6 | apt_repository: repo='deb http://www.rabbitmq.com/debian/ testing main' update_cache=no state=present | 6 | apt_repository: repo='deb http://www.rabbitmq.com/debian/ testing main' update_cache=no state=present |
7 | 7 | ||
8 | - name: Install RabbitMQ server | 8 | - name: debian | installing RabbitMQ server |
9 | apt: name={{ item }} update_cache=no force=yes state=installed | 9 | apt: name={{ item }} state=present |
10 | with_items: | 10 | with_items: |
11 | - rabbitmq-server | 11 | - rabbitmq-server |
12 | 12 | ||
13 | - name: Enable the RabbitMQ Management Console | 13 | - name: debian | enabling the RabbitMQ Management Console |
14 | rabbitmq_plugin: names=rabbitmq_management state=enabled | 14 | rabbitmq_plugin: names=rabbitmq_management state=enabled |
15 | notify: restart rabbitmq-server | 15 | notify: restart rabbitmq-server |
16 | 16 | ||
17 | - name: Ensure that the RabbitMQ service is running | 17 | - name: debian | ensuring that the RabbitMQ service is running |
18 | service: name=rabbitmq-server state=started enabled=yes | 18 | service: name=rabbitmq-server state=started enabled=yes |
19 | |||
20 | - name: check | checking to see if already clustered | ||
21 | stat: path=/etc/rabbitmq/clustered | ||
22 | register: clustered | ||
diff --git a/tasks/main.yml b/tasks/main.yml index 3752d78..edd55df 100644 --- a/tasks/main.yml +++ b/tasks/main.yml | |||
@@ -2,8 +2,12 @@ | |||
2 | - include: debian.yml | 2 | - include: debian.yml |
3 | when: ansible_os_family == "Debian" | 3 | when: ansible_os_family == "Debian" |
4 | 4 | ||
5 | - name: checking to see if already clustered | ||
6 | stat: path=/etc/rabbitmq/clustered | ||
7 | register: clustered | ||
8 | |||
5 | - include: rabbitmq_clustering.yml | 9 | - include: rabbitmq_clustering.yml |
6 | when: enable_rabbitmq_clustering and (clustered.stat.exists != True) | 10 | when: enable_rabbitmq_clustering and not clustered.stat.exists |
7 | 11 | ||
8 | - include: rabbitmq_ha_config.yml | 12 | - include: rabbitmq_ha_config.yml |
9 | when: config_rabbitmq_ha and enable_rabbitmq_clustering | 13 | when: config_rabbitmq_ha and enable_rabbitmq_clustering |
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml index 29db18c..a34ff92 100644 --- a/tasks/rabbitmq_clustering.yml +++ b/tasks/rabbitmq_clustering.yml | |||
@@ -1,40 +1,42 @@ | |||
1 | --- | 1 | --- |
2 | - name: rabbitmq_clustering | config | stopping rabbitmq app | 2 | - name: rabbitmq_clustering | stopping rabbitmq app |
3 | command: rabbitmqctl stop_app | 3 | command: rabbitmqctl stop_app |
4 | 4 | ||
5 | - name: rabbitmq_clustering | config | resetting rabbitmq app | 5 | - name: rabbitmq_clustering | resetting rabbitmq app |
6 | command: rabbitmqctl reset | 6 | command: rabbitmqctl reset |
7 | 7 | ||
8 | - name: rabbitmq_clustering | config | copy erlang cookie | 8 | - name: rabbitmq_clustering | copy erlang cookie |
9 | template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes | 9 | template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes |
10 | 10 | ||
11 | - name: rabbitmq_clustering | config | starting rabbitmq app | 11 | - name: rabbitmq_clustering | starting rabbitmq app |
12 | command: rabbitmqctl start_app | 12 | command: rabbitmqctl start_app |
13 | when: inventory_hostname == "{{ master_rabbit_node }}" | 13 | register: cluster_master |
14 | when: master_rabbit_node is defined and master_rabbit_node | ||
14 | 15 | ||
15 | - name: rabbitmq_clustering | config | sending sigterm to any running rabbitmq processes | 16 | - name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes |
16 | shell: pkill -u rabbitmq || true | 17 | shell: pkill -u rabbitmq || true |
17 | when: inventory_hostname != "{{ master_rabbit_node }}" | 18 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
18 | 19 | ||
19 | - name: rabbitmq_clustering | config | restarting rabbitmq-server | 20 | - name: rabbitmq_clustering | restarting rabbitmq-server |
20 | service: name=rabbitmq-server state=restarted | 21 | service: name=rabbitmq-server state=restarted |
21 | when: inventory_hostname != "{{ master_rabbit_node }}" | 22 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
22 | 23 | ||
23 | - name: rabbitmq_clustering | config | stopping rabbitmq app | 24 | - name: rabbitmq_clustering | stopping rabbitmq app |
24 | command: rabbitmqctl stop_app | 25 | command: rabbitmqctl stop_app |
25 | when: inventory_hostname != "{{ master_rabbit_node }}" | 26 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
26 | 27 | ||
27 | - name: rabbitmq_clustering | config | resetting rabbitmq app | 28 | - name: rabbitmq_clustering | resetting rabbitmq app |
28 | command: rabbitmqctl reset | 29 | command: rabbitmqctl reset |
29 | when: inventory_hostname != "{{ master_rabbit_node }}" | 30 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
30 | 31 | ||
31 | - name: rabbitmq_clustering | config | joining rabbitmq cluster | 32 | - name: rabbitmq_clustering | joining rabbitmq cluster |
32 | command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}' | 33 | command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}' |
33 | when: inventory_hostname != "{{ master_rabbit_node }}" | 34 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
34 | 35 | ||
35 | - name: rabbitmq_clustering | config | starting rabbitmq app | 36 | - name: rabbitmq_clustering | starting rabbitmq app |
36 | command: rabbitmqctl start_app | 37 | command: rabbitmqctl start_app |
37 | when: inventory_hostname != "{{ master_rabbit_node }}" | 38 | when: (master_rabbit_node is defined and not master_rabbit_node) and cluster_master.changed |
38 | 39 | ||
39 | - name: rabbitmq_clustering | config | marking as clustered | 40 | - name: rabbitmq_clustering | marking as clustered |
40 | file: path=/etc/rabbitmq/clustered state=touch | 41 | file: path=/etc/rabbitmq/clustered state=touch |
42 | when: cluster_master.changed | ||
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml index 5554782..3a82c59 100644 --- a/tasks/rabbitmq_ha_config.yml +++ b/tasks/rabbitmq_ha_config.yml | |||
@@ -1,30 +1,30 @@ | |||
1 | --- | 1 | --- |
2 | - name: rabbitmq_ha_config | install | install rabbitMQ admin | 2 | - name: rabbitmq_ha_config | install rabbitMQ admin |
3 | shell: wget http://guest:guest@localhost:55672/cli/rabbitmqadmin | 3 | shell: wget http://guest:guest@localhost:55672/cli/rabbitmqadmin |
4 | 4 | ||
5 | - name: Move the rabbitMQ Admin | 5 | - name: rabbitmq_ha_config | moving the rabbitMQ Admin |
6 | shell: mv rabbitmqadmin /usr/sbin | 6 | shell: mv rabbitmqadmin /usr/sbin |
7 | 7 | ||
8 | - name: Make executable rabbitMQ Admin | 8 | - name: rabbitmq_ha_config | making executable rabbitMQ Admin |
9 | shell: chmod +x /usr/sbin/rabbitmqadmin | 9 | shell: chmod +x /usr/sbin/rabbitmqadmin |
10 | notify: restart rabbitmq-server | 10 | notify: restart rabbitmq-server |
11 | 11 | ||
12 | - name: rabbitmq_ha_config | config | creating queue(s) | 12 | - name: rabbitmq_ha_config | creating queue(s) |
13 | command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable }} | 13 | command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable }} |
14 | run_once: true | 14 | run_once: true |
15 | with_items: rabbitmq_config | 15 | with_items: rabbitmq_config |
16 | 16 | ||
17 | - name: rabbitmq_ha_config | config | setting up ha on queue(s) | 17 | - 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 | 18 | rabbitmq_policy: name='ha-all' pattern='{{ item.queue_name }}' tags="{{ item.tags }}" state=present |
19 | run_once: true | 19 | run_once: true |
20 | with_items: rabbitmq_config | 20 | with_items: rabbitmq_config |
21 | 21 | ||
22 | - name: rabbitmq_ha_config | config | creating exchange(s) | 22 | - name: rabbitmq_ha_config | creating exchange(s) |
23 | command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} | 23 | command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} |
24 | run_once: true | 24 | run_once: true |
25 | with_items: rabbitmq_config | 25 | with_items: rabbitmq_config |
26 | 26 | ||
27 | - name: rabbitmq_ha_config | config | creating binding(s) | 27 | - 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 }} | 28 | command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }} |
29 | run_once: true | 29 | run_once: true |
30 | with_items: rabbitmq_config | 30 | with_items: rabbitmq_config |