aboutsummaryrefslogtreecommitdiffhomepage
path: root/Vagrant/roles/ansible-rabbitmq
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2017-04-07 23:30:56 -0400
committerLarry Smith Jr <mrlesmithjr@gmail.com>2017-04-07 23:30:56 -0400
commit3a55d2ab8ab3a399faaf25c4f46e7f2ea142edc6 (patch)
tree5d96c46e58511bc54cbd046d68fcc80b093cdafd /Vagrant/roles/ansible-rabbitmq
parentdcb10e24d902f6d20c811b0f6084b27a15cf3748 (diff)
downloadansible-rabbitmq-3a55d2ab8ab3a399faaf25c4f46e7f2ea142edc6.tar.gz
ansible-rabbitmq-3a55d2ab8ab3a399faaf25c4f46e7f2ea142edc6.tar.zst
ansible-rabbitmq-3a55d2ab8ab3a399faaf25c4f46e7f2ea142edc6.zip
Updated Vagrant testing
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
Diffstat (limited to 'Vagrant/roles/ansible-rabbitmq')
-rw-r--r--Vagrant/roles/ansible-rabbitmq/.gitignore3
-rw-r--r--Vagrant/roles/ansible-rabbitmq/.travis.yml29
-rw-r--r--Vagrant/roles/ansible-rabbitmq/README.md7
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/Vagrantfile228
-rwxr-xr-xVagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.sh23
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.yml180
-rwxr-xr-xVagrant/roles/ansible-rabbitmq/Vagrant/cleanup.sh (renamed from Vagrant/roles/ansible-rabbitmq/cleanup.sh)0
l---------Vagrant/roles/ansible-rabbitmq/Vagrant/playbook.yml1
l---------Vagrant/roles/ansible-rabbitmq/Vagrant/requirements.yml1
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/README.md118
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/Vagrantfile (renamed from Vagrant/roles/ansible-rabbitmq/Vagrantfile)0
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/ansible.cfg3
-rwxr-xr-xVagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.sh (renamed from Vagrant/roles/ansible-rabbitmq/bootstrap.sh)0
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.yml (renamed from Vagrant/roles/ansible-rabbitmq/bootstrap.yml)0
-rwxr-xr-xVagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/cleanup.sh8
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/defaults/main.yml28
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/handlers/main.yml6
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/meta/main.yml137
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/playbook.yml25
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/requirements.yml2
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/debian.yml35
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/fedora.yml39
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/main.yml21
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml70
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_ha_config.yml44
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_users.yml27
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/redhat.yml40
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/templates/erlang.cookie.j21
-rw-r--r--Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/vars/main.yml2
-rw-r--r--Vagrant/roles/ansible-rabbitmq/playbook.yml14
-rw-r--r--Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml4
-rw-r--r--Vagrant/roles/ansible-rabbitmq/tests/inventory1
-rw-r--r--Vagrant/roles/ansible-rabbitmq/tests/test.yml5
33 files changed, 1093 insertions, 9 deletions
diff --git a/Vagrant/roles/ansible-rabbitmq/.gitignore b/Vagrant/roles/ansible-rabbitmq/.gitignore
new file mode 100644
index 0000000..409a2e0
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/.gitignore
@@ -0,0 +1,3 @@
1*.retry
2*.vagrant
3.galaxy_install_info
diff --git a/Vagrant/roles/ansible-rabbitmq/.travis.yml b/Vagrant/roles/ansible-rabbitmq/.travis.yml
new file mode 100644
index 0000000..36bbf62
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/.travis.yml
@@ -0,0 +1,29 @@
1---
2language: python
3python: "2.7"
4
5# Use the new container infrastructure
6sudo: false
7
8# Install ansible
9addons:
10 apt:
11 packages:
12 - python-pip
13
14install:
15 # Install ansible
16 - pip install ansible
17
18 # Check ansible version
19 - ansible --version
20
21 # Create ansible.cfg with correct roles_path
22 - printf '[defaults]\nroles_path=../' >ansible.cfg
23
24script:
25 # Basic role syntax check
26 - ansible-playbook tests/test.yml -i tests/inventory --syntax-check
27
28notifications:
29 webhooks: https://galaxy.ansible.com/api/v1/notifications/ \ No newline at end of file
diff --git a/Vagrant/roles/ansible-rabbitmq/README.md b/Vagrant/roles/ansible-rabbitmq/README.md
index 03cd1aa..99c019d 100644
--- a/Vagrant/roles/ansible-rabbitmq/README.md
+++ b/Vagrant/roles/ansible-rabbitmq/README.md
@@ -3,6 +3,11 @@ Role Name
3 3
4Installs rabbitmq https://www.rabbitmq.com/ (Configurable...HA and Clustering ready) 4Installs rabbitmq https://www.rabbitmq.com/ (Configurable...HA and Clustering ready)
5 5
6Build Status
7------------
8
9[![Build Status](https://travis-ci.org/mrlesmithjr/ansible-rabbitmq.svg?branch=master)](https://travis-ci.org/mrlesmithjr/ansible-rabbitmq)
10
6Requirements 11Requirements
7------------ 12------------
8 13
@@ -90,7 +95,7 @@ Example Playbook
90 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}" 95 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
91 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}" 96 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
92 state: present 97 state: present
93 with_items: groups['all'] 98 with_items: "{{ groups['all'] }}"
94 99
95- hosts: all 100- hosts: all
96 become: true 101 become: true
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/Vagrantfile b/Vagrant/roles/ansible-rabbitmq/Vagrant/Vagrantfile
new file mode 100644
index 0000000..bca5718
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/Vagrantfile
@@ -0,0 +1,228 @@
1# -*- mode: ruby -*-
2# vi: set ft=ruby :
3
4# All Vagrant configuration is done below. The "2" in Vagrant.configure
5# configures the configuration version (we support older styles for
6# backwards compatibility). Please don't change it unless you know what
7# you're doing.
8
9# ---- Define number of nodes to spin up ----
10N = 3
11
12# ---- Define any custom memory/cpu requirement ----
13# if custom requirements are desired...ensure to set
14# custom_cpu_mem == true otherwise set to false
15# By default if custom requirements are defined and set below
16# any node not defined will be configured as the default...
17# which is 1vCPU/512mb...So if setting custom requirements
18# only define any node which requires more than the defaults.
19nodes = [
20 {
21 :node => "node0",
22 :box => "mrlesmithjr/trusty64",
23 :cpu => 1,
24 :mem => 1024
25 }
26]
27
28# ---- Define variables below ----
29#Define if additional disks should be added (true|false)
30additional_disks = false
31additional_disks_controller = "SATA Controller"
32#Define the number of additional disks to add
33additional_disks_num = 1
34#Define disk size in GB
35additional_disks_size = 10
36#Define if additional network adapters should be created (true|false)
37additional_nics = true
38#Define if add'l network adapters are auto configured addresses (true|false)
39additional_nics_auto_config = true
40#Define if additional network adapters should be DHCP assigned (true|false)
41additional_nics_dhcp = false
42#Define the number of additional nics to add
43additional_nics_num = 1
44ansible_groups = {
45 "test-nodes" => ["node[0:#{N-1}]"]
46}
47#Define Vagrant box to load
48box = "ubuntu/trusty64"
49#Define if custom cpu and memory requirements are needed (true|false)
50 #defined within nodes variable above
51custom_cpu_mem = false
52#Define if running desktop OS (true|false)
53desktop = false
54#Define if custom boxes should be used...defined in nodes var..
55enable_custom_boxes = false
56#Define if port forwards should be enabled (true|false)
57enable_port_forwards = false
58#Defines if nodes should be linked from master VM (true|false)
59linked_clones = false
60port_forwards = [
61 {
62 :node => "node0",
63 :guest => 3306,
64 :host => 3306
65 },
66 {
67 :node => "node0",
68 :guest => 80,
69 :host => 8080
70 },
71 {
72 :node => "node0",
73 :guest => 8000,
74 :host => 8000
75 }
76]
77#Define if provisioners should run (true|false)
78provision_nodes = true
79#Define if IP's are random assigned if not DHCP (true|false)
80random_ips = false
81#Define number of CPU cores
82 #will be ignored if custom_cpu_mem == true
83server_cpus = 1
84#Define amount of memory to assign to node(s)
85 #will be ignored if custom_cpu_mem == true
86server_memory = 512
87#Define subnet for private_network (If not using DHCP)
88subnet = "192.168.202."
89#Define starting last octet of the subnet range to begin addresses for node(s)
90subnet_ip_start = 200
91
92Vagrant.configure(2) do |config|
93
94 #Iterate over nodes
95 (1..N).each do |node_id|
96 nid = (node_id - 1)
97
98 config.vm.define "node#{nid}" do |node|
99 if enable_custom_boxes
100 #Initially no so it can be set to yes if found in custom box defined
101 box_set = "no"
102 nodes.each do |cust_box|
103 if cust_box[:node] == "node#{nid}"
104 node.vm.box = cust_box[:box]
105 box_set = "yes"
106 end
107 end
108 if box_set == "no"
109 node.vm.box = box
110 end
111 end
112 if not enable_custom_boxes
113 node.vm.box = box
114 end
115 node.vm.provider "virtualbox" do |vb|
116 if linked_clones
117 vb.linked_clone = true
118 end
119 if not custom_cpu_mem
120 vb.customize ["modifyvm", :id, "--cpus", server_cpus]
121 vb.customize ["modifyvm", :id, "--memory", server_memory]
122 end
123 if custom_cpu_mem
124 nodes.each do |cust_node|
125 if cust_node[:node] == "node#{nid}"
126 vb.customize ["modifyvm", :id, "--cpus", cust_node[:cpu]]
127 vb.customize ["modifyvm", :id, "--memory", cust_node[:mem]]
128 end
129 end
130 end
131
132 # Setup desktop environment
133 if desktop
134 vb.gui = true
135 vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"]
136 vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
137 vb.customize ["modifyvm", :id, "--ioapic", "on"]
138 vb.customize ["modifyvm", :id, "--vram", "128"]
139 vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
140 end
141
142 # Add additional disks
143 if additional_disks
144 (1..additional_disks_num).each do |disk_num|
145 dnum = (disk_num + 1)
146 ddev = ("node#{nid}_Disk#{dnum}.vdi")
147 unless File.exist?("#{ddev}")
148 vb.customize ['createhd', '--filename', ("#{ddev}"), \
149 '--variant', 'Fixed', '--size', additional_disks_size * 1024]
150 end
151 vb.customize ['storageattach', :id, '--storagectl', \
152 "#{additional_disks_controller}", '--port', dnum, '--device', 0, \
153 '--type', 'hdd', '--medium', "node#{nid}_Disk#{dnum}.vdi"]
154 end
155 end
156 end
157 node.vm.hostname = "node#{nid}"
158
159 # Define additional network adapters below
160 if additional_nics
161 if not additional_nics_dhcp
162 (1..additional_nics_num).each do |nic_num|
163 if random_ips
164 nnum = Random.rand(0..50)
165 if additional_nics_auto_config
166 node.vm.network :private_network, \
167 ip: subnet+"#{subnet_ip_start + nid + nnum}"
168 end
169 if not additional_nics_auto_config
170 node.vm.network :private_network, \
171 ip: subnet+"#{subnet_ip_start + nid + nnum}",
172 auto_config: false
173 end
174 end
175 if not random_ips
176 if additional_nics_auto_config
177 node.vm.network :private_network, \
178 ip: subnet+"#{subnet_ip_start + nid}"
179 end
180 if not additional_nics_auto_config
181 node.vm.network :private_network, \
182 ip: subnet+"#{subnet_ip_start + nid}",
183 auto_config: false
184 end
185 end
186 end
187 end
188 if additional_nics_dhcp
189 (1..additional_nics_num).each do |nic_num|
190 node.vm.network :private_network, type: "dhcp"
191 end
192 end
193 end
194
195 # Define port forwards below
196 if enable_port_forwards
197 port_forwards.each do |pf|
198 if pf[:node] == "node#{nid}"
199 node.vm.network :forwarded_port, guest: pf[:guest], \
200 host: pf[:host]
201 end
202 end
203 end
204
205 # Provisioners
206 if provision_nodes
207 if node_id == N
208 node.vm.provision "ansible" do |ansible|
209 ansible.limit = "all"
210 #runs bootstrap Ansible playbook
211 ansible.playbook = "bootstrap.yml"
212 end
213 node.vm.provision "ansible" do |ansible|
214 ansible.limit = "all"
215 #runs Ansible playbook for installing roles/executing tasks
216 ansible.playbook = "playbook.yml"
217 ansible.groups = ansible_groups
218 end
219 end
220 end
221
222 end
223 end
224 if provision_nodes
225 #runs initial shell script
226 config.vm.provision :shell, path: "bootstrap.sh", keep_color: "true"
227 end
228end
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.sh b/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.sh
new file mode 100755
index 0000000..5f1620e
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.sh
@@ -0,0 +1,23 @@
1#!/bin/bash
2if [ -f /etc/debian_version ]; then
3 codename="$(lsb_release -c | awk {'print $2}')"
4 if [[ $codename == "vivid" ]]; then
5 sudo apt-get update && \
6 sudo apt-get -y install python-simplejson
7 fi
8 if [[ $codename == "wily" ]]; then
9 sudo apt-get update && \
10 sudo apt-get -y install python-simplejson
11 fi
12 if [[ $codename == "xenial" ]]; then
13 sudo apt-get update && \
14 sudo apt-get -y install python-simplejson
15 fi
16fi
17if [ -f /etc/redhat-release ]; then
18 codename="$(gawk -F= '/^NAME/{print $2}' /etc/os-release)"
19 if [[ $codename == "Fedora" ]]; then
20 sudo dnf -y install python-devel python-dnf && \
21 sudo dnf -y group install "C Development Tools and Libraries"
22 fi
23fi
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.yml
new file mode 100644
index 0000000..fbd17cb
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/bootstrap.yml
@@ -0,0 +1,180 @@
1---
2- hosts: all
3 remote_user: vagrant
4 become: true
5 vars:
6 - host_vars_directory: './host_vars'
7 - host_vars_file: '{{ host_vars_directory }}/{{ inventory_hostname }}.yml'
8 - pri_domain_name: 'vagrant.local'
9 - ssh_key_path: '.vagrant/machines/{{ inventory_hostname }}/virtualbox/private_key'
10 - update_host_vars: true
11 roles:
12 tasks:
13 - name: updating apt cache (Debian)
14 apt:
15 update_cache: yes
16 cache_valid_time: 3600
17 when: ansible_os_family == "Debian"
18
19 - name: installing ansible pre-reqs (Debian)
20 apt:
21 name: "{{ item }}"
22 state: present
23 with_items:
24 - libffi-dev
25 - libssl-dev
26 - python-dev
27 - python-setuptools
28 when: >
29 ansible_os_family == "Debian"
30
31 - name: installing epel repo (RedHat)
32 yum:
33 name: "epel-release"
34 state: present
35 when: >
36 ansible_os_family == "RedHat" and
37 ansible_distribution != "Fedora"
38
39 - name: installing ansible pre-reqs (RedHat)
40 yum:
41 name: "{{ item }}"
42 state: present
43 with_items:
44 - libffi-devel
45 - openssl-devel
46 - python-crypto
47 - python-devel
48 - python-setuptools
49 when: >
50 ansible_os_family == "RedHat" and
51 ansible_distribution != "Fedora"
52
53 - name: installing ansible pre-reqs (Fedora)
54 dnf:
55 name: "{{ item }}"
56 state: present
57 with_items:
58 - gmp-devel
59 - libffi-devel
60 - openssl-devel
61 - python-crypto
62 - python-devel
63 - python-dnf
64 - python-setuptools
65 - redhat-rpm-config
66 when: >
67 ansible_os_family == "RedHat" and
68 ansible_distribution == "Fedora"
69
70 - name: installing ansible pre-reqs (openSUSE)
71 zypper:
72 name: "{{ item }}"
73 state: present
74 with_items:
75 - gmp-devel
76 - libffi-devel
77 - openssl-devel
78 - python-crypto
79 - python-devel
80 - python-setuptools
81 when: >
82 ansible_os_family == "openSUSE Leap"
83
84 - name: installing python pip
85 easy_install:
86 name: "pip"
87 state: present
88
89 - name: installing ansible
90 pip:
91 name: "ansible"
92 state: present
93 version: 1.9.6
94
95 - name: ensuring host_vars directory exists
96 file:
97 path: "./host_vars"
98 state: directory
99 delegate_to: localhost
100 run_once: true
101 become: false
102 when: update_host_vars is defined and update_host_vars
103
104 - name: ensuring host file exists in host_vars
105 stat:
106 path: "{{ host_vars_file }}"
107 delegate_to: localhost
108 register: host_var
109 become: false
110 when: >
111 update_host_vars is defined and
112 update_host_vars
113
114 - name: creating missing host_vars
115 file:
116 path: "{{ host_vars_file }}"
117 state: touch
118 delegate_to: localhost
119 become: false
120 when: not host_var.stat.exists
121
122 - name: updating ansible_ssh_port
123 lineinfile:
124 dest: "{{ host_vars_file }}"
125 regexp: "^ansible_ssh_port{{ ':' }}"
126 line: "ansible_ssh_port{{ ':' }} 22"
127 delegate_to: localhost
128 become: false
129 when: >
130 (update_host_vars is defined and
131 update_host_vars) and
132 (ansible_eth1 is defined or
133 ansible_enp0s8 is defined)
134
135 - name: updating ansible_ssh_host
136 lineinfile:
137 dest: "{{ host_vars_file }}"
138 regexp: "^ansible_ssh_host{{ ':' }}"
139 line: "ansible_ssh_host{{ ':' }} {{ ansible_eth1.ipv4.address }}"
140 delegate_to: localhost
141 become: false
142 when: >
143 (update_host_vars is defined and
144 update_host_vars) and
145 ansible_eth1 is defined
146
147 - name: updating ansible_ssh_host
148 lineinfile:
149 dest: "{{ host_vars_file }}"
150 regexp: "^ansible_ssh_host{{ ':' }}"
151 line: "ansible_ssh_host{{ ':' }} {{ ansible_enp0s8.ipv4.address }}"
152 delegate_to: localhost
153 become: false
154 when: >
155 (update_host_vars is defined and
156 update_host_vars) and
157 ansible_enp0s8 is defined
158
159 - name: updating ansible_ssh_key
160 lineinfile:
161 dest: "{{ host_vars_file }}"
162 regexp: "^ansible_ssh_private_key_file{{ ':' }}"
163 line: "ansible_ssh_private_key_file{{ ':' }} {{ ssh_key_path }}"
164 delegate_to: localhost
165 become: false
166 when: >
167 update_host_vars is defined and
168 update_host_vars
169
170 - name: ensuring host_vars is yaml formatted
171 lineinfile:
172 dest: "{{ host_vars_file }}"
173 regexp: "---"
174 line: "---"
175 insertbefore: BOF
176 delegate_to: localhost
177 become: false
178 when: >
179 update_host_vars is defined and
180 update_host_vars
diff --git a/Vagrant/roles/ansible-rabbitmq/cleanup.sh b/Vagrant/roles/ansible-rabbitmq/Vagrant/cleanup.sh
index a049429..a049429 100755
--- a/Vagrant/roles/ansible-rabbitmq/cleanup.sh
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/cleanup.sh
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/playbook.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/playbook.yml
new file mode 120000
index 0000000..7622583
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/playbook.yml
@@ -0,0 +1 @@
../playbook.yml \ No newline at end of file
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/requirements.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/requirements.yml
new file mode 120000
index 0000000..6e76d52
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/requirements.yml
@@ -0,0 +1 @@
../requirements.yml \ No newline at end of file
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/README.md b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/README.md
new file mode 100644
index 0000000..03cd1aa
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/README.md
@@ -0,0 +1,118 @@
1Role Name
2=========
3
4Installs rabbitmq https://www.rabbitmq.com/ (Configurable...HA and Clustering ready)
5
6Requirements
7------------
8
9Ensure hostnames are resolvable prior to clustering...either update /etc/hosts or ensure DNS is working.
10
11Vagrant
12-------
13
14Spin up a 3 node HA Cluster for testing...
15Install Ansible role on your host:
16````
17sudo ansible-galaxy install -r requirements.yml -f
18````
19Now spin up your environment...
20````
21vagrant up
22````
23When you are done testing, tear it all down...
24````
25./cleanup.sh
26````
27
28Role Variables
29--------------
30
31````
32---
33# defaults file for ansible-rabbitmq
34rabbitmq_config_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
35rabbitmq_enable_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
36rabbitmq_erlang_cookie: 'LSKNKBELKPSTDBBCHETL' #define erlang cookie for cluster...define here or in group_vars/group
37rabbitmq_erlang_cookie_file: '/var/lib/rabbitmq/.erlang.cookie'
38rabbitmq_config:
39 - queue_name: logstash
40 durable: true
41 exchange_name: logstash
42 type: direct
43 routing_key: logstash
44 tags: 'ha-mode=all,ha-sync-mode=automatic'
45rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main'
46rabbitmq_debian_repo_key: 'http://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
47rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
48rabbitmq_redhat_repo_key: 'https://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
49rabbitmq_redhat_package: 'rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch.rpm'
50rabbitmq_redhat_url: 'http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}'
51rabbitmq_redhat_version: '3.6.1'
52rabbitmq_users: #define admin user to create in order to login to WebUI
53 - name: rabbitmqadmin
54 password: rabbitmqadmin
55 vhost: /
56 configure_priv: '.*'
57 read_priv: '.*'
58 write_priv: '.*'
59 tags: 'administrator' #define comma separated list of tags to assign to user....management,policymaker,monitoring,administrator...required for management plugin. https://www.rabbitmq.com/management.html
60````
61
62example...
63group_vars/rabbitmq-cluster-nodes
64````
65---
66rabbitmq_enable_clustering: true
67rabbitmq_config_ha: false
68rabbitmq_master: ans-test-1
69````
70
71Dependencies
72------------
73
74None
75
76Example Playbook
77----------------
78
79````
80---
81- hosts: all
82 become: true
83 vars:
84 - pri_domain_name: 'test.vagrant.local'
85 roles:
86 tasks:
87 - name: updating /etc/hosts
88 lineinfile:
89 dest: /etc/hosts
90 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
91 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
92 state: present
93 with_items: groups['all']
94
95- hosts: all
96 become: true
97 vars:
98 - rabbitmq_config_ha: true
99 - rabbitmq_enable_clustering: true
100 - pri_domain_name: 'test.vagrant.local'
101 - rabbitmq_master: 'node0'
102 roles:
103 - role: ansible-rabbitmq
104 tasks:
105````
106
107License
108-------
109
110BSD
111
112Author Information
113------------------
114
115Larry Smith Jr.
116- @mrlesmithjr
117- http://everythingshouldbevirtual.com
118- mrlesmithjr [at] gmail.com
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrantfile b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/Vagrantfile
index 9c68a3d..9c68a3d 100644
--- a/Vagrant/roles/ansible-rabbitmq/Vagrantfile
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/Vagrantfile
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/ansible.cfg b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/ansible.cfg
new file mode 100644
index 0000000..5a1e589
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/ansible.cfg
@@ -0,0 +1,3 @@
1[defaults]
2host_key_checking = False
3#roles_path = ../
diff --git a/Vagrant/roles/ansible-rabbitmq/bootstrap.sh b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.sh
index 7bcf8b0..7bcf8b0 100755
--- a/Vagrant/roles/ansible-rabbitmq/bootstrap.sh
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.sh
diff --git a/Vagrant/roles/ansible-rabbitmq/bootstrap.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.yml
index 702b540..702b540 100644
--- a/Vagrant/roles/ansible-rabbitmq/bootstrap.yml
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/bootstrap.yml
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/cleanup.sh b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/cleanup.sh
new file mode 100755
index 0000000..a049429
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/cleanup.sh
@@ -0,0 +1,8 @@
1#!/bin/bash
2vagrant destroy -f
3if [ -d host_vars ]; then
4 rm -rf host_vars
5fi
6if [ -d .vagrant ]; then
7 rm -rf .vagrant
8fi
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/defaults/main.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/defaults/main.yml
new file mode 100644
index 0000000..ad22ead
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/defaults/main.yml
@@ -0,0 +1,28 @@
1---
2# defaults file for ansible-rabbitmq
3rabbitmq_config:
4 - queue_name: 'logstash'
5 durable: true
6 exchange_name: logstash
7 type: 'direct'
8 routing_key: 'logstash'
9 tags: 'ha-mode=all,ha-sync-mode=automatic'
10rabbitmq_config_ha: false #defines if rabbitmq ha should be configured...define here or in group_vars/group
11rabbitmq_debian_repo: 'deb http://www.rabbitmq.com/debian/ testing main'
12rabbitmq_debian_repo_key: 'https://www.rabbitmq.com/rabbitmq-release-signing-key.asc'
13rabbitmq_enable_clustering: false #defines if setting up a rabbitmq cluster...define here or in group_vars/group
14rabbitmq_erlang_cookie: 'LSKNKBELKPSTDBBCHETL' #define erlang cookie for cluster...define here or in group_vars/group
15rabbitmq_erlang_cookie_file: '/var/lib/rabbitmq/.erlang.cookie'
16rabbitmq_master: [] #defines the inventory host that should be considered master...define here or in group_vars/group
17rabbitmq_redhat_repo_key: 'https://www.rabbitmq.com/rabbitmq-signing-key-public.asc'
18rabbitmq_redhat_package: 'rabbitmq-server-{{ rabbitmq_redhat_version }}-1.noarch.rpm'
19rabbitmq_redhat_url: 'http://www.rabbitmq.com/releases/rabbitmq-server/v{{ rabbitmq_redhat_version }}'
20rabbitmq_redhat_version: '3.6.1'
21rabbitmq_users: #define admin user to create in order to login to WebUI
22 - name: 'rabbitmqadmin'
23 password: 'rabbitmqadmin'
24 vhost: '/'
25 configure_priv: '.*'
26 read_priv: '.*'
27 write_priv: '.*'
28 tags: 'administrator' #define comma separated list of tags to assign to user....management,policymaker,monitoring,administrator...required for management plugin. https://www.rabbitmq.com/management.html
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/handlers/main.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/handlers/main.yml
new file mode 100644
index 0000000..259ce1c
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/handlers/main.yml
@@ -0,0 +1,6 @@
1---
2# handlers file for ansible-rabbitmq
3- name: restart rabbitmq-server
4 service:
5 name: "rabbitmq-server"
6 state: restarted
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/meta/main.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/meta/main.yml
new file mode 100644
index 0000000..b25c818
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/meta/main.yml
@@ -0,0 +1,137 @@
1---
2galaxy_info:
3 author: Larry Smith Jr.
4 description: Installs rabbitmq https://www.rabbitmq.com/ (Configurable...HA and Clustering ready)
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 - 23
42 #- name: Windows
43 # versions:
44 # - all
45 # - 2012R2
46 #- name: SmartOS
47 # versions:
48 # - all
49 # - any
50 #- name: opensuse
51 # versions:
52 # - all
53 # - 12.1
54 # - 12.2
55 # - 12.3
56 # - 13.1
57 # - 13.2
58 #- name: Amazon
59 # versions:
60 # - all
61 # - 2013.03
62 # - 2013.09
63 #- name: GenericBSD
64 # versions:
65 # - all
66 # - any
67 #- name: FreeBSD
68 # versions:
69 # - all
70 # - 8.0
71 # - 8.1
72 # - 8.2
73 # - 8.3
74 # - 8.4
75 # - 9.0
76 # - 9.1
77 # - 9.1
78 # - 9.2
79 - name: Ubuntu
80 versions:
81 # - all
82 # - lucid
83 # - maverick
84 # - natty
85 # - oneiric
86 # - precise
87 # - quantal
88 # - raring
89 # - saucy
90 - trusty
91 # - utopic
92 # - vivid
93 #- name: SLES
94 # versions:
95 # - all
96 # - 10SP3
97 # - 10SP4
98 # - 11
99 # - 11SP1
100 # - 11SP2
101 # - 11SP3
102 #- name: GenericLinux
103 # versions:
104 # - all
105 # - any
106 #- name: Debian
107 # versions:
108 # - all
109 # - etch
110 # - jessie
111 # - lenny
112 # - squeeze
113 # - wheezy
114 #
115 # Below are all categories currently available. Just as with
116 # the platforms above, uncomment those that apply to your role.
117 #
118 categories:
119 #- cloud
120 #- cloud:ec2
121 #- cloud:gce
122 #- cloud:rax
123 - clustering
124 #- database
125 #- database:nosql
126 #- database:sql
127 #- development
128 #- monitoring
129 #- networking
130 #- packaging
131 - system
132 #- web
133dependencies: []
134 # List your role dependencies here, one per line. Only
135 # dependencies available via galaxy should be listed here.
136 # Be sure to remove the '[]' above if you add dependencies
137 # to this list.
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/playbook.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/playbook.yml
new file mode 100644
index 0000000..498c829
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/playbook.yml
@@ -0,0 +1,25 @@
1---
2- hosts: all
3 become: true
4 vars:
5 - pri_domain_name: 'test.vagrant.local'
6 roles:
7 tasks:
8 - name: updating /etc/hosts
9 lineinfile:
10 dest: /etc/hosts
11 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
12 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
13 state: present
14 with_items: groups['all']
15
16- hosts: all
17 become: true
18 vars:
19 - rabbitmq_config_ha: true
20 - rabbitmq_enable_clustering: true
21 - pri_domain_name: 'test.vagrant.local'
22 - rabbitmq_master: 'node0'
23 roles:
24 - role: ansible-rabbitmq
25 tasks:
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/requirements.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/requirements.yml
new file mode 100644
index 0000000..a1f51cb
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/requirements.yml
@@ -0,0 +1,2 @@
1---
2- src: https://github.com/mrlesmithjr/ansible-rabbitmq.git
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/debian.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/debian.yml
new file mode 100644
index 0000000..a031ead
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/debian.yml
@@ -0,0 +1,35 @@
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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/fedora.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/fedora.yml
new file mode 100644
index 0000000..3d92963
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/fedora.yml
@@ -0,0 +1,39 @@
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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/main.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/main.yml
new file mode 100644
index 0000000..bd82f93
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/main.yml
@@ -0,0 +1,21 @@
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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml
new file mode 100644
index 0000000..9dece46
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml
@@ -0,0 +1,70 @@
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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_ha_config.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_ha_config.yml
new file mode 100644
index 0000000..8811b6d
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_ha_config.yml
@@ -0,0 +1,44 @@
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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_users.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_users.yml
new file mode 100644
index 0000000..8bce8b2
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/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: (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/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/redhat.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/redhat.yml
new file mode 100644
index 0000000..484597d
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/tasks/redhat.yml
@@ -0,0 +1,40 @@
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
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/templates/erlang.cookie.j2 b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/templates/erlang.cookie.j2
new file mode 100644
index 0000000..edd141f
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/templates/erlang.cookie.j2
@@ -0,0 +1 @@
{{ rabbitmq_erlang_cookie }}
diff --git a/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/vars/main.yml b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/vars/main.yml
new file mode 100644
index 0000000..5977bc8
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/Vagrant/roles/ansible-rabbitmq/vars/main.yml
@@ -0,0 +1,2 @@
1---
2# vars file for ansible-rabbitmq
diff --git a/Vagrant/roles/ansible-rabbitmq/playbook.yml b/Vagrant/roles/ansible-rabbitmq/playbook.yml
index 498c829..1968320 100644
--- a/Vagrant/roles/ansible-rabbitmq/playbook.yml
+++ b/Vagrant/roles/ansible-rabbitmq/playbook.yml
@@ -2,7 +2,7 @@
2- hosts: all 2- hosts: all
3 become: true 3 become: true
4 vars: 4 vars:
5 - pri_domain_name: 'test.vagrant.local' 5 pri_domain_name: 'test.vagrant.local'
6 roles: 6 roles:
7 tasks: 7 tasks:
8 - name: updating /etc/hosts 8 - name: updating /etc/hosts
@@ -11,15 +11,15 @@
11 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}" 11 regexp: "^{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
12 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}" 12 line: "{{ hostvars[item].ansible_ssh_host }} {{ item }} {{ item }}.{{ pri_domain_name }}"
13 state: present 13 state: present
14 with_items: groups['all'] 14 with_items: "{{ groups['all'] }}"
15 15
16- hosts: all 16- hosts: all
17 become: true 17 become: true
18 vars: 18 vars:
19 - rabbitmq_config_ha: true 19 pri_domain_name: 'test.vagrant.local'
20 - rabbitmq_enable_clustering: true 20 rabbitmq_config_ha: true
21 - pri_domain_name: 'test.vagrant.local' 21 rabbitmq_enable_clustering: true
22 - rabbitmq_master: 'node0' 22 rabbitmq_master: 'node0'
23 roles: 23 roles:
24 - role: ansible-rabbitmq 24 - role: ansible-rabbitmq
25 tasks: 25 tasks:
diff --git a/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml b/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml
index 9dece46..5134c50 100644
--- a/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml
+++ b/Vagrant/roles/ansible-rabbitmq/tasks/rabbitmq_clustering.yml
@@ -1,9 +1,11 @@
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 5
5- name: rabbitmq_clustering | resetting rabbitmq app 6- name: rabbitmq_clustering | resetting rabbitmq app
6 command: rabbitmqctl reset 7 command: rabbitmqctl reset
8 when: inventory_hostname != "{{ rabbitmq_master }}"
7 9
8- name: rabbitmq_clustering | stopping rabbitmq-server 10- name: rabbitmq_clustering | stopping rabbitmq-server
9 service: 11 service:
@@ -55,7 +57,7 @@
55 when: inventory_hostname != "{{ rabbitmq_master }}" 57 when: inventory_hostname != "{{ rabbitmq_master }}"
56 58
57- name: rabbitmq_clustering | joining rabbitmq cluster 59- name: rabbitmq_clustering | joining rabbitmq cluster
58 command: rabbitmqctl join_cluster 'rabbit@{{ rabbitmq_master }}' 60 command: rabbitmqctl join_cluster "rabbit@{{ hostvars[rabbitmq_master]['ansible_hostname'] }}"
59 register: cluster_joined 61 register: cluster_joined
60 when: inventory_hostname != "{{ rabbitmq_master }}" 62 when: inventory_hostname != "{{ rabbitmq_master }}"
61 63
diff --git a/Vagrant/roles/ansible-rabbitmq/tests/inventory b/Vagrant/roles/ansible-rabbitmq/tests/inventory
new file mode 100644
index 0000000..d18580b
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/tests/inventory
@@ -0,0 +1 @@
localhost \ No newline at end of file
diff --git a/Vagrant/roles/ansible-rabbitmq/tests/test.yml b/Vagrant/roles/ansible-rabbitmq/tests/test.yml
new file mode 100644
index 0000000..9b96df5
--- /dev/null
+++ b/Vagrant/roles/ansible-rabbitmq/tests/test.yml
@@ -0,0 +1,5 @@
1---
2- hosts: localhost
3 remote_user: root
4 roles:
5 - ansible-rabbitmq \ No newline at end of file