aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorLarry Smith Jr <mrlesmithjr@gmail.com>2016-12-03 17:50:41 -0500
committerLarry Smith Jr <mrlesmithjr@gmail.com>2016-12-03 17:50:41 -0500
commit8f8673fb8dfa2bd4fa2694cbfdcb6eed54e502de (patch)
treeaaaf71ac94a4bd065cefd8b3c75603efe3703d89
parentda8e343df912e94703a8094f5e62d4c1bcc57345 (diff)
downloadansible-rabbitmq-8f8673fb8dfa2bd4fa2694cbfdcb6eed54e502de.tar.gz
ansible-rabbitmq-8f8673fb8dfa2bd4fa2694cbfdcb6eed54e502de.tar.zst
ansible-rabbitmq-8f8673fb8dfa2bd4fa2694cbfdcb6eed54e502de.zip
Updated gitignore
Signed-off-by: Larry Smith Jr <mrlesmithjr@gmail.com>
-rw-r--r--.gitignore3
-rw-r--r--README.md118
-rw-r--r--Vagrantfile63
-rw-r--r--ansible.cfg3
-rwxr-xr-xbootstrap.sh14
-rw-r--r--bootstrap.yml152
-rwxr-xr-xcleanup.sh8
-rw-r--r--defaults/main.yml28
-rw-r--r--handlers/main.yml6
-rw-r--r--meta/.galaxy_install_info1
-rw-r--r--meta/main.yml137
-rw-r--r--playbook.yml25
-rw-r--r--requirements.yml2
-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
-rw-r--r--templates/erlang.cookie.j21
-rw-r--r--vars/main.yml2
22 files changed, 3 insertions, 836 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..409a2e0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
1*.retry
2*.vagrant
3.galaxy_install_info
diff --git a/README.md b/README.md
deleted file mode 100644
index 03cd1aa..0000000
--- a/README.md
+++ /dev/null
@@ -1,118 +0,0 @@
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/Vagrantfile b/Vagrantfile
deleted file mode 100644
index 9c68a3d..0000000
--- a/Vagrantfile
+++ /dev/null
@@ -1,63 +0,0 @@
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.
8Vagrant.configure(2) do |config|
9 #Define if running desktop OS to yes otherwise no
10 Desktop = "no"
11 #Define the number of nodes to spin up
12 N = 3
13
14 #Iterate over nodes
15 (1..N).each do |node_id|
16 nid = (node_id - 1)
17
18 config.vm.define "node#{nid}" do |node|
19 node.vm.box = "mrlesmithjr/centos-7"
20 node.vm.provider "virtualbox" do |vb|
21 vb.memory = "1024"
22 vb.cpus = "1"
23 if Desktop == "yes"
24 vb.gui = true
25 vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxvga"]
26 vb.customize ["modifyvm", :id, "--accelerate3d", "on"]
27 vb.customize ["modifyvm", :id, "--ioapic", "on"]
28 vb.customize ["modifyvm", :id, "--vram", "128"]
29 vb.customize ["modifyvm", :id, "--hwvirtex", "on"]
30 end
31 end
32 node.vm.hostname = "node#{nid}"
33 ### Define additional network adapters below
34 node.vm.network :private_network, ip: "192.168.202.#{200 + nid}"
35
36 ### Define port forwards below
37# node.vm.network "forwarded_port", guest: 80, host: "#{8080 + nid}"
38# node.vm.network "forwarded_port", guest: 3000, host: "#{3000 + nid}"
39
40 if node_id == N
41 node.vm.provision :shell, path: "bootstrap.sh", keep_color: "true" #runs initial shell script
42 node.vm.provision "ansible" do |ansible| #runs bootstrap Ansible playbook
43 ansible.limit = "all"
44 ansible.playbook = "bootstrap.yml"
45 end
46 node.vm.provision "ansible" do |ansible| #runs Ansible playbook for installing roles/executing tasks
47 ansible.limit = "all"
48 ansible.playbook = "playbook.yml"
49 ansible.groups = {
50 "test-nodes" => [
51 "node0",
52 "node1"
53 ],
54 "prod-nodes" => [
55 "node2"
56 ]
57 }
58 end
59 end
60
61 end
62 end
63end
diff --git a/ansible.cfg b/ansible.cfg
deleted file mode 100644
index 5a1e589..0000000
--- a/ansible.cfg
+++ /dev/null
@@ -1,3 +0,0 @@
1[defaults]
2host_key_checking = False
3#roles_path = ../
diff --git a/bootstrap.sh b/bootstrap.sh
deleted file mode 100755
index 7bcf8b0..0000000
--- a/bootstrap.sh
+++ /dev/null
@@ -1,14 +0,0 @@
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 && sudo apt-get -y install python-simplejson
6 fi
7fi
8if [ -f /etc/redhat-release ]; then
9 codename="$(gawk -F= '/^NAME/{print $2}' /etc/os-release)"
10 if [ $codename == "Fedora" ]; then
11 sudo dnf -y install python-devel python-dnf python-pip && \
12 sudo dnf -y group install "C Development Tools and Libraries"
13 fi
14fi
diff --git a/bootstrap.yml b/bootstrap.yml
deleted file mode 100644
index 702b540..0000000
--- a/bootstrap.yml
+++ /dev/null
@@ -1,152 +0,0 @@
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 - python-dev
25 - python-pip
26 when: ansible_os_family == "Debian"
27
28 - name: installing epel repo (RedHat)
29 yum:
30 name: "epel-release"
31 state: present
32 when: >
33 ansible_os_family == "RedHat" and
34 ansible_distribution != "Fedora"
35
36 - name: installing ansible pre-reqs (RedHat)
37 yum:
38 name: "{{ item }}"
39 state: present
40 with_items:
41 - python-devel
42 - python-dnf
43 - python-pip
44 when: >
45 ansible_os_family == "RedHat" and
46 ansible_distribution != "Fedora"
47
48 - name: installing ansible pre-reqs (Fedora)
49 dnf:
50 name: "{{ item }}"
51 state: present
52 with_items:
53 - gmp-devel
54 - python-crypto
55 - python-devel
56 - python-dnf
57 - python-pip
58 when: >
59 ansible_os_family == "RedHat" and
60 ansible_distribution == "Fedora"
61
62 - name: installing ansible
63 pip:
64 name: "ansible"
65 state: present
66
67 - name: ensuring host_vars directory exists
68 file:
69 path: "./host_vars"
70 state: directory
71 delegate_to: localhost
72 run_once: true
73 become: false
74 when: update_host_vars is defined and update_host_vars
75
76 - name: ensuring host file exists in host_vars
77 stat:
78 path: "{{ host_vars_file }}"
79 delegate_to: localhost
80 register: host_var
81 become: false
82 when: >
83 update_host_vars is defined and
84 update_host_vars
85
86 - name: creating missing host_vars
87 file:
88 path: "{{ host_vars_file }}"
89 state: touch
90 delegate_to: localhost
91 become: false
92 when: not host_var.stat.exists
93
94 - name: updating ansible_ssh_port
95 lineinfile:
96 dest: "{{ host_vars_file }}"
97 regexp: "^ansible_ssh_port{{ ':' }}"
98 line: "ansible_ssh_port{{ ':' }} 22"
99 delegate_to: localhost
100 become: false
101 when: >
102 (update_host_vars is defined and
103 update_host_vars) and
104 (ansible_eth1 is defined or
105 ansible_enp0s8 is defined)
106
107 - name: updating ansible_ssh_host
108 lineinfile:
109 dest: "{{ host_vars_file }}"
110 regexp: "^ansible_ssh_host{{ ':' }}"
111 line: "ansible_ssh_host{{ ':' }} {{ ansible_eth1.ipv4.address }}"
112 delegate_to: localhost
113 become: false
114 when: >
115 (update_host_vars is defined and
116 update_host_vars) and
117 ansible_eth1 is defined
118
119 - name: updating ansible_ssh_host
120 lineinfile:
121 dest: "{{ host_vars_file }}"
122 regexp: "^ansible_ssh_host{{ ':' }}"
123 line: "ansible_ssh_host{{ ':' }} {{ ansible_enp0s8.ipv4.address }}"
124 delegate_to: localhost
125 become: false
126 when: >
127 (update_host_vars is defined and
128 update_host_vars) and
129 ansible_enp0s8 is defined
130
131 - name: updating ansible_ssh_key
132 lineinfile:
133 dest: "{{ host_vars_file }}"
134 regexp: "^ansible_ssh_private_key_file{{ ':' }}"
135 line: "ansible_ssh_private_key_file{{ ':' }} {{ ssh_key_path }}"
136 delegate_to: localhost
137 become: false
138 when: >
139 update_host_vars is defined and
140 update_host_vars
141
142 - name: ensuring host_vars is yaml formatted
143 lineinfile:
144 dest: "{{ host_vars_file }}"
145 regexp: "---"
146 line: "---"
147 insertbefore: BOF
148 delegate_to: localhost
149 become: false
150 when: >
151 update_host_vars is defined and
152 update_host_vars
diff --git a/cleanup.sh b/cleanup.sh
deleted file mode 100755
index a049429..0000000
--- a/cleanup.sh
+++ /dev/null
@@ -1,8 +0,0 @@
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/defaults/main.yml b/defaults/main.yml
deleted file mode 100644
index ad22ead..0000000
--- a/defaults/main.yml
+++ /dev/null
@@ -1,28 +0,0 @@
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/handlers/main.yml b/handlers/main.yml
deleted file mode 100644
index 259ce1c..0000000
--- a/handlers/main.yml
+++ /dev/null
@@ -1,6 +0,0 @@
1---
2# handlers file for ansible-rabbitmq
3- name: restart rabbitmq-server
4 service:
5 name: "rabbitmq-server"
6 state: restarted
diff --git a/meta/.galaxy_install_info b/meta/.galaxy_install_info
deleted file mode 100644
index 2e2e5ee..0000000
--- a/meta/.galaxy_install_info
+++ /dev/null
@@ -1 +0,0 @@
1{install_date: 'Mon Nov 9 03:40:19 2015', version: ''}
diff --git a/meta/main.yml b/meta/main.yml
deleted file mode 100644
index b25c818..0000000
--- a/meta/main.yml
+++ /dev/null
@@ -1,137 +0,0 @@
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/playbook.yml b/playbook.yml
deleted file mode 100644
index 498c829..0000000
--- a/playbook.yml
+++ /dev/null
@@ -1,25 +0,0 @@
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/requirements.yml b/requirements.yml
deleted file mode 100644
index a1f51cb..0000000
--- a/requirements.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1---
2- src: https://github.com/mrlesmithjr/ansible-rabbitmq.git
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
diff --git a/templates/erlang.cookie.j2 b/templates/erlang.cookie.j2
deleted file mode 100644
index edd141f..0000000
--- a/templates/erlang.cookie.j2
+++ /dev/null
@@ -1 +0,0 @@
1{{ rabbitmq_erlang_cookie }}
diff --git a/vars/main.yml b/vars/main.yml
deleted file mode 100644
index 5977bc8..0000000
--- a/vars/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
1---
2# vars file for ansible-rabbitmq