aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md44
-rw-r--r--defaults/main.yml4
-rw-r--r--handlers/main.yml4
-rw-r--r--meta/main.yml136
-rw-r--r--tasks/main.yml29
-rw-r--r--tasks/rabbitmq_clustering.yml40
-rw-r--r--tasks/rabbitmq_ha_config.yml30
-rw-r--r--templates/erlang.cookie.j21
-rw-r--r--vars/main.yml2
9 files changed, 290 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..bc57b4c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,44 @@
1Role Name
2=========
3
4Installs rabbitmq https://www.rabbitmq.com/
5
6Requirements
7------------
8
9Any pre-requisites that may not be covered by Ansible itself or the role should be mentioned here. For instance, if the role uses the EC2 module, it may be a good idea to mention in this section that the boto package is required.
10
11Role Variables
12--------------
13
14````
15enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster
16config_rabbitmq_ha: false #defines if rabbitmq ha should be configured
17````
18
19Dependencies
20------------
21
22A list of other roles hosted on Galaxy should go here, plus any details in regards to parameters that may need to be set for other roles, or variables that are used from other roles.
23
24Example Playbook
25----------------
26
27Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too:
28
29 - hosts: servers
30 roles:
31 - { role: mrlesmithjr.rabbitmq }
32
33License
34-------
35
36BSD
37
38Author Information
39------------------
40
41Larry Smith Jr.
42- @mrlesmithjr
43- http://everythingshouldbevirtual.com
44- mrlesmithjr [at] gmail.com
diff --git a/defaults/main.yml b/defaults/main.yml
new file mode 100644
index 0000000..8ca8a4f
--- /dev/null
+++ b/defaults/main.yml
@@ -0,0 +1,4 @@
1---
2# defaults file for ansible-rabbitmq
3enable_rabbitmq_clustering: false #defines if setting up a rabbitmq cluster
4config_rabbitmq_ha: false #defines if rabbitmq ha should be configured
diff --git a/handlers/main.yml b/handlers/main.yml
new file mode 100644
index 0000000..54a880b
--- /dev/null
+++ b/handlers/main.yml
@@ -0,0 +1,4 @@
1---
2# handlers file for ansible-rabbitmq
3- name: restart rabbitmq-server
4 service: name=rabbitmq-server state=restarted
diff --git a/meta/main.yml b/meta/main.yml
new file mode 100644
index 0000000..0bbfc73
--- /dev/null
+++ b/meta/main.yml
@@ -0,0 +1,136 @@
1---
2galaxy_info:
3 author: Larry Smith Jr.
4 description: Installs rabbitmq
5 #company: your company (optional)
6 # Some suggested licenses:
7 # - BSD (default)
8 # - MIT
9 # - GPLv2
10 # - GPLv3
11 # - Apache
12 # - CC-BY
13 license: license (GPLv2, CC-BY, etc)
14 min_ansible_version: 1.2
15 #
16 # Below are all platforms currently available. Just uncomment
17 # the ones that apply to your role. If you don't see your
18 # platform on this list, let us know and we'll get it added!
19 #
20 platforms:
21 #- name: EL
22 # versions:
23 # - all
24 # - 5
25 # - 6
26 # - 7
27 #- name: GenericUNIX
28 # versions:
29 # - all
30 # - any
31 #- name: Fedora
32 # versions:
33 # - all
34 # - 16
35 # - 17
36 # - 18
37 # - 19
38 # - 20
39 # - 21
40 # - 22
41 #- name: Windows
42 # versions:
43 # - all
44 # - 2012R2
45 #- name: SmartOS
46 # versions:
47 # - all
48 # - any
49 #- name: opensuse
50 # versions:
51 # - all
52 # - 12.1
53 # - 12.2
54 # - 12.3
55 # - 13.1
56 # - 13.2
57 #- name: Amazon
58 # versions:
59 # - all
60 # - 2013.03
61 # - 2013.09
62 #- name: GenericBSD
63 # versions:
64 # - all
65 # - any
66 #- name: FreeBSD
67 # versions:
68 # - all
69 # - 8.0
70 # - 8.1
71 # - 8.2
72 # - 8.3
73 # - 8.4
74 # - 9.0
75 # - 9.1
76 # - 9.1
77 # - 9.2
78 - name: Ubuntu
79 versions:
80 # - all
81 # - lucid
82 # - maverick
83 # - natty
84 # - oneiric
85 # - precise
86 # - quantal
87 # - raring
88 # - saucy
89 - trusty
90 # - utopic
91 # - vivid
92 #- name: SLES
93 # versions:
94 # - all
95 # - 10SP3
96 # - 10SP4
97 # - 11
98 # - 11SP1
99 # - 11SP2
100 # - 11SP3
101 #- name: GenericLinux
102 # versions:
103 # - all
104 # - any
105 #- name: Debian
106 # versions:
107 # - all
108 # - etch
109 # - jessie
110 # - lenny
111 # - squeeze
112 # - wheezy
113 #
114 # Below are all categories currently available. Just as with
115 # the platforms above, uncomment those that apply to your role.
116 #
117 categories:
118 #- cloud
119 #- cloud:ec2
120 #- cloud:gce
121 #- cloud:rax
122 #- clustering
123 #- database
124 #- database:nosql
125 #- database:sql
126 #- development
127 #- monitoring
128 #- networking
129 #- packaging
130 - system
131 #- web
132dependencies: []
133 # List your role dependencies here, one per line. Only
134 # dependencies available via galaxy should be listed here.
135 # Be sure to remove the '[]' above if you add dependencies
136 # to this list.
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..e74c1e5
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,29 @@
1---
2# tasks file for ansible-rabbitmq
3- name: Add the RabbitMQ public GPG key to the apt repo
4 apt_key: url=http://www.rabbitmq.com/rabbitmq-signing-key-public.asc state=present
5
6- name: Add RabbitMQ to the sources list
7 apt_repository: repo='deb http://www.rabbitmq.com/debian/ testing main' update_cache=no state=present
8
9- name: Install RabbitMQ server
10 apt: name={{ item }} update_cache=no force=yes state=installed
11 with_items:
12 - rabbitmq-server
13
14- name: Enable the RabbitMQ Management Console
15 rabbitmq_plugin: names=rabbitmq_management state=enabled
16 notify: restart rabbitmq-server
17
18- name: Ensure that the RabbitMQ service is running
19 service: name=rabbitmq-server state=started enabled=yes
20
21- name: check | checking to see if already clustered
22 stat: path=/etc/rabbitmq/clustered
23 register: clustered
24
25- include: rabbitmq_clustering.yml
26 when: enable_rabbitmq_clustering and (clustered.stat.exists != True)
27
28- include: rabbitmq_ha_config.yml
29 when: config_rabbitmq_ha and enable_rabbitmq_clustering
diff --git a/tasks/rabbitmq_clustering.yml b/tasks/rabbitmq_clustering.yml
new file mode 100644
index 0000000..29db18c
--- /dev/null
+++ b/tasks/rabbitmq_clustering.yml
@@ -0,0 +1,40 @@
1---
2- name: rabbitmq_clustering | config | stopping rabbitmq app
3 command: rabbitmqctl stop_app
4
5- name: rabbitmq_clustering | config | resetting rabbitmq app
6 command: rabbitmqctl reset
7
8- name: rabbitmq_clustering | config | copy erlang cookie
9 template: src=erlang.cookie.j2 dest=/var/lib/rabbitmq/.erlang.cookie owner=rabbitmq group=rabbitmq mode=0400 backup=yes
10
11- name: rabbitmq_clustering | config | starting rabbitmq app
12 command: rabbitmqctl start_app
13 when: inventory_hostname == "{{ master_rabbit_node }}"
14
15- name: rabbitmq_clustering | config | sending sigterm to any running rabbitmq processes
16 shell: pkill -u rabbitmq || true
17 when: inventory_hostname != "{{ master_rabbit_node }}"
18
19- name: rabbitmq_clustering | config | restarting rabbitmq-server
20 service: name=rabbitmq-server state=restarted
21 when: inventory_hostname != "{{ master_rabbit_node }}"
22
23- name: rabbitmq_clustering | config | stopping rabbitmq app
24 command: rabbitmqctl stop_app
25 when: inventory_hostname != "{{ master_rabbit_node }}"
26
27- name: rabbitmq_clustering | config | resetting rabbitmq app
28 command: rabbitmqctl reset
29 when: inventory_hostname != "{{ master_rabbit_node }}"
30
31- name: rabbitmq_clustering | config | joining rabbitmq cluster
32 command: rabbitmqctl join_cluster 'rabbit@{{ master_rabbit_node }}'
33 when: inventory_hostname != "{{ master_rabbit_node }}"
34
35- name: rabbitmq_clustering | config | starting rabbitmq app
36 command: rabbitmqctl start_app
37 when: inventory_hostname != "{{ master_rabbit_node }}"
38
39- name: rabbitmq_clustering | config | marking as clustered
40 file: path=/etc/rabbitmq/clustered state=touch
diff --git a/tasks/rabbitmq_ha_config.yml b/tasks/rabbitmq_ha_config.yml
new file mode 100644
index 0000000..5554782
--- /dev/null
+++ b/tasks/rabbitmq_ha_config.yml
@@ -0,0 +1,30 @@
1---
2- name: rabbitmq_ha_config | install | install rabbitMQ admin
3 shell: wget http://guest:guest@localhost:55672/cli/rabbitmqadmin
4
5- name: Move the rabbitMQ Admin
6 shell: mv rabbitmqadmin /usr/sbin
7
8- name: Make executable rabbitMQ Admin
9 shell: chmod +x /usr/sbin/rabbitmqadmin
10 notify: restart rabbitmq-server
11
12- name: rabbitmq_ha_config | config | creating queue(s)
13 command: rabbitmqadmin declare queue name={{ item.queue_name }} durable={{ item.durable }}
14 run_once: true
15 with_items: rabbitmq_config
16
17- name: rabbitmq_ha_config | config | setting up ha on queue(s)
18 rabbitmq_policy: name='ha-all' pattern='{{ item.queue_name }}' tags="{{ item.tags }}" state=present
19 run_once: true
20 with_items: rabbitmq_config
21
22- name: rabbitmq_ha_config | config | creating exchange(s)
23 command: rabbitmqadmin declare exchange name={{ item.exchange_name }} type={{ item.type }}
24 run_once: true
25 with_items: rabbitmq_config
26
27- name: rabbitmq_ha_config | 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 }}
29 run_once: true
30 with_items: rabbitmq_config
diff --git a/templates/erlang.cookie.j2 b/templates/erlang.cookie.j2
new file mode 100644
index 0000000..cb398e7
--- /dev/null
+++ b/templates/erlang.cookie.j2
@@ -0,0 +1 @@
{{ erlang_cookie }}
diff --git a/vars/main.yml b/vars/main.yml
new file mode 100644
index 0000000..5977bc8
--- /dev/null
+++ b/vars/main.yml
@@ -0,0 +1,2 @@
1---
2# vars file for ansible-rabbitmq