aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'tasks')
-rw-r--r--tasks/config.yml7
-rw-r--r--tasks/debian.yml6
-rw-r--r--tasks/fedora.yml7
-rw-r--r--tasks/main.yml17
-rw-r--r--tasks/rabbitmq_clustering.yml56
-rw-r--r--tasks/rabbitmq_ha_config.yml27
-rw-r--r--tasks/rabbitmq_users.yml39
-rw-r--r--tasks/redhat.yml7
8 files changed, 120 insertions, 46 deletions
diff --git a/tasks/config.yml b/tasks/config.yml
new file mode 100644
index 0000000..9ea5da2
--- /dev/null
+++ b/tasks/config.yml
@@ -0,0 +1,7 @@
1---
2- name: config | Configuring RabbitMQ
3 template:
4 src: "etc/rabbitmq/rabbitmq.config.j2"
5 dest: "/etc/rabbitmq/rabbitmq.config"
6 become: true
7 notify: "restart rabbitmq-server"
diff --git a/tasks/debian.yml b/tasks/debian.yml
index a031ead..b25d39b 100644
--- a/tasks/debian.yml
+++ b/tasks/debian.yml
@@ -3,22 +3,26 @@
3 apt_key: 3 apt_key:
4 url: "{{ rabbitmq_debian_repo_key }}" 4 url: "{{ rabbitmq_debian_repo_key }}"
5 state: present 5 state: present
6 become: true
6 7
7- name: debian | adding RabbitMQ repo 8- name: debian | adding RabbitMQ repo
8 apt_repository: 9 apt_repository:
9 repo: "{{ rabbitmq_debian_repo }}" 10 repo: "{{ rabbitmq_debian_repo }}"
10 state: present 11 state: present
11 register: "rabbitmq_repo_added" 12 register: "rabbitmq_repo_added"
13 become: true
12 14
13- name: debian | updating apt cache 15- name: debian | updating apt cache
14 apt: 16 apt:
15 update_cache: yes 17 update_cache: yes
18 become: true
16 when: rabbitmq_repo_added.changed 19 when: rabbitmq_repo_added.changed
17 20
18- name: debian | installing RabbitMQ server 21- name: debian | installing RabbitMQ server
19 apt: 22 apt:
20 name: "{{ item }}" 23 name: "{{ item }}"
21 state: present 24 state: present
25 become: true
22 with_items: 26 with_items:
23 - rabbitmq-server 27 - rabbitmq-server
24 28
@@ -26,6 +30,7 @@
26 rabbitmq_plugin: 30 rabbitmq_plugin:
27 names: rabbitmq_management 31 names: rabbitmq_management
28 state: enabled 32 state: enabled
33 become: true
29 notify: restart rabbitmq-server 34 notify: restart rabbitmq-server
30 35
31- name: debian | ensuring that the RabbitMQ service is running 36- name: debian | ensuring that the RabbitMQ service is running
@@ -33,3 +38,4 @@
33 name: rabbitmq-server 38 name: rabbitmq-server
34 state: started 39 state: started
35 enabled: yes 40 enabled: yes
41 become: true
diff --git a/tasks/fedora.yml b/tasks/fedora.yml
index 3d92963..6ac9c03 100644
--- a/tasks/fedora.yml
+++ b/tasks/fedora.yml
@@ -3,6 +3,7 @@
3 dnf: 3 dnf:
4 name: "{{ item }}" 4 name: "{{ item }}"
5 state: present 5 state: present
6 become: true
6 with_items: 7 with_items:
7 - wget 8 - wget
8 9
@@ -10,30 +11,36 @@
10 dnf: 11 dnf:
11 name: "erlang" 12 name: "erlang"
12 state: present 13 state: present
14 become: true
13 15
14- name: fedora | adding RabbitMQ public GPG key 16- name: fedora | adding RabbitMQ public GPG key
15 rpm_key: 17 rpm_key:
16 key: "{{ rabbitmq_redhat_repo_key }}" 18 key: "{{ rabbitmq_redhat_repo_key }}"
17 state: present 19 state: present
20 become: true
18 21
19- name: fedora | downloading RabbitMQ 22- name: fedora | downloading RabbitMQ
20 get_url: 23 get_url:
21 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" 24 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
22 dest: "/opt/{{ rabbitmq_redhat_package }}" 25 dest: "/opt/{{ rabbitmq_redhat_package }}"
26 become: true
23 27
24- name: fedora | installing RabbitMQ 28- name: fedora | installing RabbitMQ
25 dnf: 29 dnf:
26 name: "/opt/{{ rabbitmq_redhat_package }}" 30 name: "/opt/{{ rabbitmq_redhat_package }}"
27 state: present 31 state: present
32 become: true
28 33
29- name: fedora | starting and enabling RabbitMQ service 34- name: fedora | starting and enabling RabbitMQ service
30 service: 35 service:
31 name: "rabbitmq-server" 36 name: "rabbitmq-server"
32 state: started 37 state: started
33 enabled: yes 38 enabled: yes
39 become: true
34 40
35- name: fedora | enabling the RabbitMQ Management Console 41- name: fedora | enabling the RabbitMQ Management Console
36 rabbitmq_plugin: 42 rabbitmq_plugin:
37 names: rabbitmq_management 43 names: rabbitmq_management
38 state: enabled 44 state: enabled
39 notify: restart rabbitmq-server 45 notify: restart rabbitmq-server
46 become: true
diff --git a/tasks/main.yml b/tasks/main.yml
index bd82f93..1da06c4 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -3,19 +3,30 @@
3 when: ansible_os_family == "Debian" 3 when: ansible_os_family == "Debian"
4 4
5- include: redhat.yml 5- include: redhat.yml
6 when: ansible_distribution == "CentOS" or ansible_distribution == "Red Hat Enterprise Linux" 6 when: >
7 ansible_distribution == "CentOS" or
8 ansible_distribution == "Red Hat Enterprise Linux"
7 9
8- include: fedora.yml 10- include: fedora.yml
9 when: ansible_distribution == "Fedora" 11 when: ansible_distribution == "Fedora"
10 12
13- include: config.yml
14 when: rabbitmq_config_service
15
11- name: checking to see if already clustered 16- name: checking to see if already clustered
12 stat: path=/etc/rabbitmq/clustered 17 stat: path=/etc/rabbitmq/clustered
13 register: clustered 18 register: clustered
14 19
15- include: rabbitmq_clustering.yml 20- include: rabbitmq_clustering.yml
16 when: rabbitmq_enable_clustering and (clustered.stat.exists != True) 21 when: >
22 rabbitmq_enable_clustering and
23 not clustered['stat']['exists']
17 24
18- include: rabbitmq_ha_config.yml 25- include: rabbitmq_ha_config.yml
19 when: rabbitmq_config_ha and rabbitmq_enable_clustering 26 when: >
27 rabbitmq_config_ha and
28 rabbitmq_enable_clustering and
29 rabbitmq_config is defined
20 30
21- include: rabbitmq_users.yml 31- include: rabbitmq_users.yml
32 when: rabbitmq_users is defined
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml
index 5134c50..9e48590 100644
--- a/tasks/rabbitmq_clustering.yml
+++ b/tasks/rabbitmq_clustering.yml
@@ -1,21 +1,30 @@
1--- 1---
2- name: rabbitmq_clustering | stopping rabbitmq app 2- name: rabbitmq_clustering | stopping rabbitmq app
3 command: rabbitmqctl stop_app 3 command: rabbitmqctl stop_app
4 when: inventory_hostname != "{{ rabbitmq_master }}" 4 become: true
5 when: inventory_hostname != rabbitmq_master
5 6
6- name: rabbitmq_clustering | resetting rabbitmq app 7- name: rabbitmq_clustering | resetting rabbitmq app
7 command: rabbitmqctl reset 8 command: rabbitmqctl reset
8 when: inventory_hostname != "{{ rabbitmq_master }}" 9 become: true
10 when: inventory_hostname != rabbitmq_master
9 11
10- name: rabbitmq_clustering | stopping rabbitmq-server 12- name: rabbitmq_clustering | stopping rabbitmq-server
11 service: 13 service:
12 name: rabbitmq-server 14 name: rabbitmq-server
13 state: stopped 15 state: stopped
16 become: true
14 17
15#- name: grabbing erlang cookie 18- name: rabbitmq_clustering | Capturing Erlang Cookie On Master
16# shell: cat /var/lib/rabbitmq/.erlang.cookie 19 command: "cat {{ rabbitmq_erlang_cookie_file }}"
17# register: rabbitmq_erlang_cookie 20 become: true
18# when: inventory_hostname == "{{ rabbitmq_master }}" 21 register: "rabbitmq_erlang_cookie"
22 when: inventory_hostname == rabbitmq_master
23
24- name: rabbitmq_clustering | Setting Erlang Cookie Of Master on Non-Master
25 set_fact:
26 rabbitmq_erlang_cookie: "{{ hostvars[rabbitmq_master]['rabbitmq_erlang_cookie']['stdout'] }}"
27 when: inventory_hostname != rabbitmq_master
19 28
20- name: rabbitmq_clustering | copy erlang cookie 29- name: rabbitmq_clustering | copy erlang cookie
21 template: 30 template:
@@ -24,49 +33,62 @@
24 owner: rabbitmq 33 owner: rabbitmq
25 group: rabbitmq 34 group: rabbitmq
26 mode: 0400 35 mode: 0400
27 backup: yes #backing up in case the need to recover 36 # backing up in case the need to recover
28# when: inventory_hostname != "{{ rabbitmq_master }}" 37 backup: yes
38 become: true
39 when: inventory_hostname != rabbitmq_master
29 40
30- name: rabbitmq_clustering | restarting rabbitmq-server on master 41- name: rabbitmq_clustering | restarting rabbitmq-server on master
31 service: 42 service:
32 name: rabbitmq-server 43 name: rabbitmq-server
33 state: restarted 44 state: restarted
34 when: inventory_hostname == "{{ rabbitmq_master }}" 45 become: true
46 when: inventory_hostname == rabbitmq_master
35 47
36- name: rabbitmq_clustering | starting rabbitmq app on master 48- name: rabbitmq_clustering | starting rabbitmq app on master
37 command: rabbitmqctl start_app 49 command: rabbitmqctl start_app
38 register: cluster_master 50 register: cluster_master
39 when: inventory_hostname == "{{ rabbitmq_master }}" 51 become: true
52 when: inventory_hostname == rabbitmq_master
40 53
41- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes 54- name: rabbitmq_clustering | sending sigterm to any running rabbitmq processes
42 shell: pkill -u rabbitmq || true 55 shell: pkill -u rabbitmq || true
43 when: inventory_hostname != "{{ rabbitmq_master }}" 56 become: true
57 when: inventory_hostname != rabbitmq_master
44 58
45- name: rabbitmq_clustering | restarting rabbitmq-server 59- name: rabbitmq_clustering | restarting rabbitmq-server
46 service: 60 service:
47 name: rabbitmq-server 61 name: rabbitmq-server
48 state: restarted 62 state: restarted
49 when: inventory_hostname != "{{ rabbitmq_master }}" 63 become: true
64 when: inventory_hostname != rabbitmq_master
50 65
51- name: rabbitmq_clustering | stopping rabbitmq app 66- name: rabbitmq_clustering | stopping rabbitmq app
52 command: rabbitmqctl stop_app 67 command: rabbitmqctl stop_app
53 when: inventory_hostname != "{{ rabbitmq_master }}" 68 become: true
69 when: inventory_hostname != rabbitmq_master
54 70
55- name: rabbitmq_clustering | resetting rabbitmq app 71- name: rabbitmq_clustering | resetting rabbitmq app
56 command: rabbitmqctl reset 72 command: rabbitmqctl reset
57 when: inventory_hostname != "{{ rabbitmq_master }}" 73 become: true
74 when: inventory_hostname != rabbitmq_master
58 75
59- name: rabbitmq_clustering | joining rabbitmq cluster 76- name: rabbitmq_clustering | joining rabbitmq cluster
60 command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}" 77 command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}"
61 register: cluster_joined 78 register: cluster_joined
62 when: inventory_hostname != "{{ rabbitmq_master }}" 79 become: true
80 when: inventory_hostname != rabbitmq_master
63 81
64- name: rabbitmq_clustering | starting rabbitmq app 82- name: rabbitmq_clustering | starting rabbitmq app
65 command: rabbitmqctl start_app 83 command: rabbitmqctl start_app
66 when: inventory_hostname != "{{ rabbitmq_master }}" 84 become: true
85 when: inventory_hostname != rabbitmq_master
67 86
68- name: rabbitmq_clustering | marking as clustered 87- name: rabbitmq_clustering | marking as clustered
69 file: 88 file:
70 path: /etc/rabbitmq/clustered 89 path: /etc/rabbitmq/clustered
71 state: touch 90 state: touch
72 when: cluster_master.changed or cluster_joined.changed 91 become: true
92 when: >
93 cluster_master['changed'] or
94 cluster_joined['changed']
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
index 8811b6d..bf74957 100644
--- a/tasks/rabbitmq_ha_config.yml
+++ b/tasks/rabbitmq_ha_config.yml
@@ -6,39 +6,46 @@
6 6
7- name: rabbitmq_ha_config | install rabbitMQ admin 7- name: rabbitmq_ha_config | install rabbitMQ admin
8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin 8 shell: wget http://guest:guest@localhost:15672/cli/rabbitmqadmin
9 when: not rabbitmqadmin_check.stat.exists 9 become: true
10 when: not rabbitmqadmin_check['stat']['exists']
10 11
11- name: rabbitmq_ha_config | moving the rabbitMQ Admin 12- name: rabbitmq_ha_config | moving the rabbitMQ Admin
12 shell: mv rabbitmqadmin /usr/sbin 13 shell: mv rabbitmqadmin /usr/sbin
13 when: not rabbitmqadmin_check.stat.exists 14 become: true
15 when: not rabbitmqadmin_check['stat']['exists']
14 16
15- name: rabbitmq_ha_config | making executable rabbitMQ Admin 17- name: rabbitmq_ha_config | making executable rabbitMQ Admin
16 shell: chmod +x /usr/sbin/rabbitmqadmin 18 shell: chmod +x /usr/sbin/rabbitmqadmin
17 notify: restart rabbitmq-server 19 notify: restart rabbitmq-server
18 when: not rabbitmqadmin_check.stat.exists 20 become: true
21 when: not rabbitmqadmin_check['stat']['exists']
19 22
20- name: rabbitmq_ha_config | creating queue(s) 23- name: rabbitmq_ha_config | creating queue(s)
21 command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable|lower }} 24 command: rabbitmqadmin declare queue name={{ item['queue_name'] }} durable={{ item['durable']|lower }}
22 run_once: true 25 run_once: true
26 become: true
23 with_items: "{{ rabbitmq_config }}" 27 with_items: "{{ rabbitmq_config }}"
24 28
25- name: rabbitmq_ha_config | setting up ha on queue(s) 29- name: rabbitmq_ha_config | setting up ha on queue(s)
26 rabbitmq_policy: 30 rabbitmq_policy:
27 name: "ha-all" 31 name: "ha-all"
28 pattern: "{{ item.queue_name }}" 32 pattern: "{{ item['queue_name'] }}"
29 tags: "{{ item.tags }}" 33 tags: "{{ item['tags'] }}"
30 state: present 34 state: present
31 run_once: true 35 run_once: true
36 become: true
32 with_items: "{{ rabbitmq_config }}" 37 with_items: "{{ rabbitmq_config }}"
33 38
34- name: rabbitmq_ha_config | creating exchange(s) 39- name: rabbitmq_ha_config | creating exchange(s)
35 command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }} 40 command: rabbitmqadmin declare exchange name={{ item['exchange_name'] }} type={{ item['type'] }}
36 run_once: true 41 run_once: true
42 become: true
37 with_items: "{{ rabbitmq_config }}" 43 with_items: "{{ rabbitmq_config }}"
38 when: item.exchange_name is defined 44 when: item['exchange_name'] is defined
39 45
40- name: rabbitmq_ha_config | creating binding(s) 46- 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 }} 47 command: rabbitmqadmin declare binding source={{ item['exchange_name'] }} destination_type="queue" destination={{ item['queue_name'] }} routing_key={{ item['routing_key'] }}
42 run_once: true 48 run_once: true
49 become: true
43 with_items: "{{ rabbitmq_config }}" 50 with_items: "{{ rabbitmq_config }}"
44 when: item.exchange_name is defined 51 when: item['exchange_name'] is defined
diff --git a/tasks/rabbitmq_users.yml b/tasks/rabbitmq_users.yml
index 8bce8b2..98e45e2 100644
--- a/tasks/rabbitmq_users.yml
+++ b/tasks/rabbitmq_users.yml
@@ -1,27 +1,34 @@
1--- 1---
2- name: rabbitmq_users | creating rabbitmq users 2- name: rabbitmq_users | creating rabbitmq users
3 rabbitmq_user: 3 rabbitmq_user:
4 name: "{{ item.name }}" 4 name: "{{ item['name'] }}"
5 password: "{{ item.password }}" 5 password: "{{ item['password'] }}"
6 vhost: "{{ item.vhost }}" 6 vhost: "{{ item['vhost'] }}"
7 configure_priv: "{{ item.configure_priv }}" 7 configure_priv: "{{ item['configure_priv'] }}"
8 read_priv: "{{ item.read_priv }}" 8 read_priv: "{{ item['read_priv'] }}"
9 write_priv: "{{ item.write_priv }}" 9 write_priv: "{{ item['write_priv'] }}"
10 tags: "{{ item.tags }}" 10 tags: "{{ item['tags'] }}"
11 state: present 11 state: present
12 become: true
12 with_items: "{{ rabbitmq_users }}" 13 with_items: "{{ rabbitmq_users }}"
13 when: (rabbitmq_enable_clustering is defined and not rabbitmq_enable_clustering) or rabbitmq_enable_clustering is not defined 14 when: >
15 (rabbitmq_enable_clustering is defined and
16 not rabbitmq_enable_clustering) or
17 rabbitmq_enable_clustering is not defined
14 18
15- name: rabbitmq_users | creating rabbitmq users 19- name: rabbitmq_users | creating rabbitmq users
16 rabbitmq_user: 20 rabbitmq_user:
17 name: "{{ item.name }}" 21 name: "{{ item['name'] }}"
18 password: "{{ item.password }}" 22 password: "{{ item['password'] }}"
19 vhost: "{{ item.vhost }}" 23 vhost: "{{ item['vhost'] }}"
20 configure_priv: "{{ item.configure_priv }}" 24 configure_priv: "{{ item['configure_priv'] }}"
21 read_priv: "{{ item.read_priv }}" 25 read_priv: "{{ item['read_priv'] }}"
22 write_priv: "{{ item.write_priv }}" 26 write_priv: "{{ item['write_priv'] }}"
23 tags: "{{ item.tags }}" 27 tags: "{{ item['tags'] }}"
24 state: present 28 state: present
25 run_once: yes 29 run_once: yes
30 become: true
26 with_items: "{{ rabbitmq_users }}" 31 with_items: "{{ rabbitmq_users }}"
27 when: (rabbitmq_enable_clustering is defined and rabbitmq_enable_clustering) 32 when: >
33 rabbitmq_enable_clustering is defined and
34 rabbitmq_enable_clustering
diff --git a/tasks/redhat.yml b/tasks/redhat.yml
index 484597d..afa714c 100644
--- a/tasks/redhat.yml
+++ b/tasks/redhat.yml
@@ -3,6 +3,7 @@
3 yum: 3 yum:
4 name: "{{ item }}" 4 name: "{{ item }}"
5 state: present 5 state: present
6 become: true
6 with_items: 7 with_items:
7 - epel-release 8 - epel-release
8 - wget 9 - wget
@@ -11,30 +12,36 @@
11 yum: 12 yum:
12 name: "erlang" 13 name: "erlang"
13 state: present 14 state: present
15 become: true
14 16
15- name: redhat | adding RabbitMQ public GPG key 17- name: redhat | adding RabbitMQ public GPG key
16 rpm_key: 18 rpm_key:
17 key: "{{ rabbitmq_redhat_repo_key }}" 19 key: "{{ rabbitmq_redhat_repo_key }}"
18 state: present 20 state: present
21 become: true
19 22
20- name: redhat | downloading RabbitMQ 23- name: redhat | downloading RabbitMQ
21 get_url: 24 get_url:
22 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}" 25 url: "{{ rabbitmq_redhat_url }}/{{ rabbitmq_redhat_package }}"
23 dest: "/opt/{{ rabbitmq_redhat_package }}" 26 dest: "/opt/{{ rabbitmq_redhat_package }}"
27 become: true
24 28
25- name: redhat | installing RabbitMQ 29- name: redhat | installing RabbitMQ
26 yum: 30 yum:
27 name: "/opt/{{ rabbitmq_redhat_package }}" 31 name: "/opt/{{ rabbitmq_redhat_package }}"
28 state: present 32 state: present
33 become: true
29 34
30- name: redhat | starting and enabling RabbitMQ service 35- name: redhat | starting and enabling RabbitMQ service
31 service: 36 service:
32 name: "rabbitmq-server" 37 name: "rabbitmq-server"
33 state: started 38 state: started
34 enabled: yes 39 enabled: yes
40 become: true
35 41
36- name: redhat | enabling the RabbitMQ Management Console 42- name: redhat | enabling the RabbitMQ Management Console
37 rabbitmq_plugin: 43 rabbitmq_plugin:
38 names: rabbitmq_management 44 names: rabbitmq_management
39 state: enabled 45 state: enabled
40 notify: restart rabbitmq-server 46 notify: restart rabbitmq-server
47 become: true