aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'tasks')
-rw-r--r--tasks/debian.yml35
-rw-r--r--tasks/fedora.yml39
-rw-r--r--tasks/main.yml21
-rw-r--r--tasks/rabbitmq_clustering.yml70
-rw-r--r--tasks/rabbitmq_ha_config.yml44
-rw-r--r--tasks/rabbitmq_users.yml27
-rw-r--r--tasks/redhat.yml40
7 files changed, 0 insertions, 276 deletions
diff --git a/tasks/debian.yml b/tasks/debian.yml
deleted file mode 100644
index a031ead..0000000
--- a/tasks/debian.yml
+++ /dev/null
@@ -1,35 +0,0 @@
1---
2- name: debian | adding RabbitMQ public GPG key to the apt repo
3 apt_key:
4 url: "{{ rabbitmq_debian_repo_key }}"
5 state: present
6
7- name: debian | adding RabbitMQ repo
8 apt_repository:
9 repo: "{{ rabbitmq_debian_repo }}"
10 state: present
11 register: "rabbitmq_repo_added"
12
13- name: debian | updating apt cache
14 apt:
15 update_cache: yes
16 when: rabbitmq_repo_added.changed
17
18- name: debian | installing RabbitMQ server
19 apt:
20 name: "{{ item }}"
21 state: present
22 with_items:
23 - rabbitmq-server
24
25- name: debian | enabling the RabbitMQ Management Console
26 rabbitmq_plugin:
27 names: rabbitmq_management
28 state: enabled
29 notify: restart rabbitmq-server
30
31- name: debian | ensuring that the RabbitMQ service is running
32 service:
33 name: rabbitmq-server
34 state: started
35 enabled: yes
diff --git a/tasks/fedora.yml b/tasks/fedora.yml
deleted file mode 100644
index 3d92963..0000000
--- a/tasks/fedora.yml
+++ /dev/null
@@ -1,39 +0,0 @@
1---
2- name: fedora | installing pre-reqs
3 dnf:
4 name: "{{ item }}"
5 state: present
6 with_items:
7 - wget
8
9- name: fedora | installing erlang
10 dnf:
11 name: "erlang"
12 state: present
13
14- name: fedora | adding RabbitMQ public GPG key
15 rpm_key:
16 key: "{{ rabbitmq_redhat_repo_key }}"
17 state: present
18
19- name: fedora | downloading RabbitMQ
20 get_url:
21 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
22 dest: "/opt/{{ rabbitmq_redhat_package }}"
23
24- name: fedora | installing RabbitMQ
25 dnf:
26 name: "/opt/{{ rabbitmq_redhat_package }}"
27 state: present
28
29- name: fedora | starting and enabling RabbitMQ service
30 service:
31 name: "rabbitmq-server"
32 state: started
33 enabled: yes
34
35- name: fedora | enabling the RabbitMQ Management Console
36 rabbitmq_plugin:
37 names: rabbitmq_management
38 state: enabled
39 notify: restart rabbitmq-server
diff --git a/tasks/main.yml b/tasks/main.yml
deleted file mode 100644
index bd82f93..0000000
--- a/tasks/main.yml
+++ /dev/null
@@ -1,21 +0,0 @@
1# tasks file for ansible-rabbitmq
2- include: debian.yml
3 when: ansible_os_family == "Debian"
4
5- include: redhat.yml
6 when: ansible_distribution == "CentOS" or ansible_distribution == "Red Hat Enterprise Linux"
7
8- include: fedora.yml
9 when: ansible_distribution == "Fedora"
10
11- name: checking to see if already clustered
12 stat: path=/etc/rabbitmq/clustered
13 register: clustered
14
15- include: rabbitmq_clustering.yml
16 when: rabbitmq_enable_clustering and (clustered.stat.exists != True)
17
18- include: rabbitmq_ha_config.yml
19 when: rabbitmq_config_ha and rabbitmq_enable_clustering
20
21- include: rabbitmq_users.yml
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml
deleted file mode 100644
index 9dece46..0000000
--- a/tasks/rabbitmq_clustering.yml
+++ /dev/null
@@ -1,70 +0,0 @@
1---
2- name: rabbitmq_clustering | stopping rabbitmq app
3 command: rabbitmqctl stop_app
4
5- name: rabbitmq_clustering | resetting rabbitmq app
6 command: rabbitmqctl reset
7
8- name: rabbitmq_clustering | stopping rabbitmq-server
9 service:
10 name: rabbitmq-server
11 state: stopped
12
13#- name: grabbing erlang cookie
14# shell: cat /var/lib/rabbitmq/.erlang.cookie
15# register: rabbitmq_erlang_cookie
16# when: inventory_hostname == "{{ rabbitmq_master }}"
17
18- name: rabbitmq_clustering | copy erlang cookie
19 template:
20 src: erlang.cookie.j2
21 dest: "{{ rabbitmq_erlang_cookie_file }}"
22 owner: rabbitmq
23 group: rabbitmq
24 mode: 0400
25 backup: yes #backing up in case the need to recover
26# when: inventory_hostname != "{{ rabbitmq_master }}"
27
28- name: rabbitmq_clustering | restarting rabbitmq-server on master
29 service:
30 name: rabbitmq-server
31 state: restarted
32 when: inventory_hostname == "{{ rabbitmq_master }}"
33
34- name: rabbitmq_clustering | starting rabbitmq app on master
35 command: rabbitmqctl start_app
36 register: cluster_master
37 when: inventory_hostname == "{{ rabbitmq_master }}"
38
39- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
40 shell: pkill -u rabbitmq || true
41 when: inventory_hostname != "{{ rabbitmq_master }}"
42
43- name: rabbitmq_clustering | restarting rabbitmq-server
44 service:
45 name: rabbitmq-server
46 state: restarted
47 when: inventory_hostname != "{{ rabbitmq_master }}"
48
49- name: rabbitmq_clustering | stopping rabbitmq app
50 command: rabbitmqctl stop_app
51 when: inventory_hostname != "{{ rabbitmq_master }}"
52
53- name: rabbitmq_clustering | resetting rabbitmq app
54 command: rabbitmqctl reset
55 when: inventory_hostname != "{{ rabbitmq_master }}"
56
57- name: rabbitmq_clustering | joining rabbitmq cluster
58 command: rabbitmqctl join_cluster 'rabbit@{{ rabbitmq_master }}'
59 register: cluster_joined
60 when: inventory_hostname != "{{ rabbitmq_master }}"
61
62- name: rabbitmq_clustering | starting rabbitmq app
63 command: rabbitmqctl start_app
64 when: inventory_hostname != "{{ rabbitmq_master }}"
65
66- name: rabbitmq_clustering | marking as clustered
67 file:
68 path: /etc/rabbitmq/clustered
69 state: touch
70 when: cluster_master.changed or cluster_joined.changed
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
deleted file mode 100644
index 8811b6d..0000000
--- a/tasks/rabbitmq_ha_config.yml
+++ /dev/null
@@ -1,44 +0,0 @@
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
9 when: not rabbitmqadmin_check.stat.exists
10
11- name: rabbitmq_ha_config | moving the rabbitMQ Admin
12 shell: mv rabbitmqadmin /usr/sbin
13 when: not rabbitmqadmin_check.stat.exists
14
15- name: rabbitmq_ha_config | making executable rabbitMQ Admin
16 shell: chmod +x /usr/sbin/rabbitmqadmin
17 notify: restart rabbitmq-server
18 when: not rabbitmqadmin_check.stat.exists
19
20- name: rabbitmq_ha_config | creating queue(s)
21 command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }}
22 run_once: true
23 with_items: "{{ rabbitmq_config }}"
24
25- name: rabbitmq_ha_config | setting up ha on queue(s)
26 rabbitmq_policy:
27 name: "ha-all"
28 pattern: "{{ item.queue_name }}"
29 tags: "{{ item.tags }}"
30 state: present
31 run_once: true
32 with_items: "{{ rabbitmq_config }}"
33
34- name: rabbitmq_ha_config | creating exchange(s)
35 command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }}
36 run_once: true
37 with_items: "{{ rabbitmq_config }}"
38 when: item.exchange_name is defined
39
40- name: rabbitmq_ha_config | creating binding(s)
41 command: rabbitmqadmin declare binding source={{ item.exchange_name }} destination_type="queue" destination={{ item.queue_name }} routing_key={{ item.routing_key }}
42 run_once: true
43 with_items: "{{ rabbitmq_config }}"
44 when: item.exchange_name is defined
diff --git a/tasks/rabbitmq_users.yml b/tasks/rabbitmq_users.yml
deleted file mode 100644
index 8bce8b2..0000000
--- a/tasks/rabbitmq_users.yml
+++ /dev/null
@@ -1,27 +0,0 @@
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: (rabbitmq_enable_clustering is defined and not rabbitmq_enable_clustering) or rabbitmq_enable_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: (rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering)
diff --git a/tasks/redhat.yml b/tasks/redhat.yml
deleted file mode 100644
index 484597d..0000000
--- a/tasks/redhat.yml
+++ /dev/null
@@ -1,40 +0,0 @@
1---
2- name: redhat | installing pre-reqs
3 yum:
4 name: "{{ item }}"
5 state: present
6 with_items:
7 - epel-release
8 - wget
9
10- name: redhat | installing erlang
11 yum:
12 name: "erlang"
13 state: present
14
15- name: redhat | adding RabbitMQ public GPG key
16 rpm_key:
17 key: "{{ rabbitmq_redhat_repo_key }}"
18 state: present
19
20- name: redhat | downloading RabbitMQ
21 get_url:
22 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
23 dest: "/opt/{{ rabbitmq_redhat_package }}"
24
25- name: redhat | installing RabbitMQ
26 yum:
27 name: "/opt/{{ rabbitmq_redhat_package }}"
28 state: present
29
30- name: redhat | starting and enabling RabbitMQ service
31 service:
32 name: "rabbitmq-server"
33 state: started
34 enabled: yes
35
36- name: redhat | enabling the RabbitMQ Management Console
37 rabbitmq_plugin:
38 names: rabbitmq_management
39 state: enabled
40 notify: restart rabbitmq-server