Skip to content

Commit 0aa7664

Browse files
committed
initial commit
1 parent 38e5e49 commit 0aa7664

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1223
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.*.sw*
2+
.vagrant/
3+
.kitchen/

.kitchen.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
3+
driver :
4+
name : <%= if ENV['TRAVIS'] then 'localhost' else 'vagrant' end %>
5+
box : "ubuntu/trusty64"
6+
customize :
7+
cpus : 2
8+
memory : 2048
9+
10+
verifier :
11+
name : serverspec
12+
remote_exec : false
13+
14+
provisioner:
15+
name : ansible_push
16+
verbose : "vvvv"
17+
ansible_config : "test/ansible.cfg"
18+
ansible_playbook_bin : "ansible-playbook"
19+
idempotency_test : True
20+
diff : True
21+
sudo : <%= if ENV['TRAVIS'] then 'True' else 'False' end %>
22+
raw_arguments : <%= if ENV['TRAVIS'] then '-c local' else '' end %>
23+
extra_vars : { 'kitchen_connection': '<%= if ENV["TRAVIS"] then "local" else "smart" end %>', 'kitchen_hosts': '<%= if ENV["TRAVIS"] then "localhost" else "all" end %>' }
24+
use_instance_name : true
25+
groups :
26+
rabbitmq-cluster :
27+
- "cluster-1-docker-u14"
28+
- "cluster-2-docker-u14"
29+
- "cluster-3-docker-u14"
30+
platforms:
31+
- name : docker-u14
32+
driver_config :
33+
image : quay.io/hellofresh/kitchen-base
34+
platform : ubuntu
35+
driver :
36+
name : docker
37+
38+
suites :
39+
- name : standalone
40+
provisioner :
41+
playbook : "test/integration/standalone/standalone.yml"
42+
verifier :
43+
patterns : [ test/integration/standalone/serverspec/*_spec.rb ]
44+
driver_config :
45+
run_options : "-p 192.168.99.100:22:22"
46+
47+
- name : cluster_1
48+
provisioner :
49+
playbook : "test/integration/cluster_1/cluster_1.yml"
50+
verifier :
51+
patterns : [ test/integration/cluster_1/serverspec/*_spec.rb ]
52+
driver_config :
53+
run_options : --ip=172.17.0.11

.travis.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
language: python
3+
python: "2.7"
4+
before_install:
5+
- sudo apt-get update -qq
6+
install:
7+
# Install Ansible.
8+
- pip install ansible
9+
10+
# Create an inventory file for testing.
11+
- "printf 'rabbit-standalone ansible_ssh_host=localhost' > inventory"
12+
script:
13+
# Check the role/playbook's syntax.
14+
- "ansible-playbook -i inventory vagrant/site.yml --syntax-check"
15+
16+
# NOTE(retr0h): Testing standalone until we can test a cluster with travis.
17+
- "ansible-playbook -vvvv -i inventory vagrant/standalone.yml --connection=local --sudo"

Gemfile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source 'https://rubygems.org'
2+
3+
#gem 'net-ssh','~> 2.9'
4+
# Could
5+
gem 'kitchen-verifier-serverspec','~> 0.5.0'
6+
gem 'kitchen-ansiblepush'
7+
gem 'kitchen-docker'
8+
gem 'serverspec'

README.md

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Announce
2+
3+
Long time no update. I'm back on this playbook again, I'll be merging fixes (url,
4+
key checking,...) in master and releasing a working tagged version.
5+
6+
Then I'll focus on creating a next branche that will be the version 2.0 of this
7+
playbook. The main things I plan to do with the version 2 is going to separate
8+
the installation steps from the pure configuration. I don't want to support a
9+
gazillion OS in one playbook. Thus, you'll be able to make a
10+
ansible-playbook-rabbitmq-install-my-little-snowflak-os yourself :)
11+
12+
Thank you all for all the participation!
13+
14+
# Rabbitmq Playbook
15+
16+
Playbook to install and configure rabbitmq. Will come with various
17+
configuration tweaking later on.
18+
19+
If you wish to discuss modifications, or help to support more platforms, open
20+
an issue.
21+
22+
## Installation
23+
24+
Use Ansible galaxy to install this playbook:
25+
26+
$ ansible-galaxy install Mayeu.RabbitMQ,1.4.0
27+
28+
The `master` branch should currently be considered instable. Please avoid using
29+
it for something else than test purpose :)
30+
31+
## Supported system
32+
33+
Currently only Debian Jessie and Wheezy on amd64 are supported. Patch welcome
34+
to support other distribution or OS.
35+
36+
## Semantic versioning 2.0.0
37+
38+
Starting with the commit
39+
[67c608826a140868a71854ce3129b5f3d67ddcce](https://github.com/Mayeu/ansible-playbook-rabbitmq/commit/67c608826a140868a71854ce3129b5f3d67ddcce),
40+
this playbook use semantic versioning. Following the specification, and since
41+
the playbook is used in production and I want to avoid breaking the
42+
compatibility, the first version number is 1.0.0
43+
44+
The public API defined in the semantic versioning correspond to the settings
45+
available to the user. Breaking the API (incrementing from `X.Y.Z` to
46+
`(X+1).Y.Z`) in this context mean that the user need to change variable name
47+
for its playbook to run.
48+
49+
Any new feature added (from `X.Y.Z` to `X.(Y+1).Z`) should have a working
50+
default value that need no user interaction by default. If a feature addition
51+
require user interaction, then it is not a minor upgrade, but a major one.
52+
53+
## Role Variables
54+
55+
### Installation
56+
57+
|Name|Type|Description|Default|
58+
|----|----|-----------|-------|
59+
`rabbitmq_os_package`|Bool|When true uses the default package proposed by the OS or distribution instead of the one distributed by RabbitMQ.|`false`|
60+
61+
62+
### Environment
63+
64+
|Name|Type|Description|Default|
65+
|----|----|-----------|-------|
66+
`rabbitmq_conf_env`|Hash|Set environment variable|undef|
67+
68+
Exemple:
69+
70+
```yaml
71+
rabbitmq_conf_env:
72+
RABBITMQ_ROCKS: correct
73+
```
74+
75+
Will generate:
76+
77+
```
78+
RABBITMQ_ROCKS="correct"
79+
```
80+
81+
### Certificate
82+
83+
|Name|Type|Description|Default|
84+
|----|----|-----------|-------|
85+
`rabbitmq_cacert`|String|Path of the CA certificate file.|`files/rabbitmq_cacert.pem`
86+
`rabbitmq_server_key`|String|Path of the SSL key file.|`files/rabbitmq_server_key.pem`
87+
`rabbitmq_server_cert`|String|Path of the SSL certificate file.|`files/rabbitmq_server_cert.pem`
88+
`rabbitmq_ssl`|Boolean|Define if we need to use SSL|`true`
89+
90+
### Default configuration file
91+
92+
|Name|Type|Description|Default|
93+
|----|----|-----------|-------|
94+
`rabbitmq_conf_tcp_listeners_address`|String|listening address for the tcp interface|`''`
95+
`rabbitmq_conf_tcp_listeners_port`|Integer|listening port for the tcp interface|`5672`
96+
`rabbitmq_conf_ssl_listeners_address`|String|listening address for the ssl interface|`'0.0.0.0'`
97+
`rabbitmq_conf_ssl_listeners_port`|Integer|listening port for the ssl interface|`5671`
98+
`rabbitmq_conf_ssl_options_cacertfile`|String|Path the CA certificate|`"/etc/rabbitmq/ssl/cacert.pem"`
99+
`rabbitmq_conf_ssl_options_certfile`|String|Path to the server certificate|`"/etc/rabbitmq/ssl/server_cert.pem"`
100+
`rabbitmq_conf_ssl_options_keyfile`|String|Path to the private key file|`"/etc/rabbitmq/ssl/server_key.pem"`
101+
`rabbitmq_conf_ssl_options_fail_if_no_peer_cert`|Boolean|Value of the `fail_if_no_peer_cert` SSL option|`"true"`
102+
103+
### Plugins
104+
105+
|Name|Type|Description|Default|
106+
|----|----|-----------|-------|
107+
`rabbitmq_new_only`|String|Add plugins as new, without deactivating other plugins|`'no'`
108+
`rabbitmq_plugins`|String|List|List of plugins to activate|`[]`
109+
110+
### Vhost
111+
112+
|Name|Type|Description|Default|
113+
|----|----|-----------|-------|
114+
`rabbitmq_vhost_definitions`|List|Define the list of vhost to create|`[]`
115+
`rabbitmq_users_definitions`|List of hash|Define the users, and associated vhost and password (see below)|`[]`
116+
117+
Defining the vhosts configuration
118+
119+
```yaml
120+
rabbitmq_vhost_definitions:
121+
- name: vhost1
122+
node: node_name #Optional, defaults to "rabbit"
123+
tracing: yes #Optional, defaults to "no"
124+
```
125+
126+
Defining the users configuration:
127+
128+
```yaml
129+
rabbitmq_users_definitions:
130+
- vhost: vhost1
131+
user: user1
132+
password: password1
133+
node: node_name # Optional, defaults to "rabbit"
134+
configure_priv: "^resource.*" # Optional, defaults to ".*"
135+
read_priv: "^$" # Disallow reading.
136+
write_priv: "^$" # Disallow writing.
137+
- vhost: vhost1
138+
user: user2
139+
password: password2
140+
force: no
141+
tags: # Optional, user tags
142+
- administrator
143+
```
144+
145+
## Cluster
146+
147+
# Limitations
148+
If you remove a node from inventory and node is still running it will not be removed
149+
150+
### Federation
151+
152+
|Name|Type|Description|Default|
153+
|----|----|-----------|-------|
154+
`rabbitmq_federation`|Boolean|Define if we need to setup federation|`false`
155+
`rabbitmq_federation_configuration`|List of hashes|Define all the federation we need to setup|Not defined
156+
`rabbitmq_policy_configuration`|List of hashes|Define all the federation we need to setup|Not defined
157+
158+
Defining the federation upstream configuration:
159+
160+
```yaml
161+
rabbitmq_federation_upstream:
162+
- name: upstream name
163+
vhost: local vhost to federate
164+
value: json description of the federation
165+
local_username: the local username for the federation
166+
```
167+
168+
See the [RabbitMQ documentation](http://www.rabbitmq.com/federation.html) for
169+
the possible JSON value.
170+
171+
Defining the policy configuration:
172+
173+
```yaml
174+
rabbitmq_policy_configuration:
175+
- name: name of the policy
176+
vhost: vhost where the policy will be applied
177+
pattern: pattern of the policy
178+
tags: description of the policy in dict form # exemple: "ha-mode=all"
179+
```
180+
181+
## Files required
182+
183+
You have to put the needed certificates in your `files/` folder, for example:
184+
185+
files/
186+
|- cacert.crt
187+
|- myserver_key.key
188+
|- myserver_cert.crt
189+
190+
And then configure the role:
191+
192+
```yaml
193+
rabbitmq_cacert: files/cacert.crt
194+
rabbitmq_server_key: files/myserver_key.key
195+
rabbitmq_server_cert: files/myserver_cert.crt
196+
```
197+
198+
## Testing
199+
200+
There is some tests that try to provision a VM using Vagrant. Just launch them
201+
with:
202+
203+
$ vagrant up # for test with Debian jessie
204+
$ export VAGRANT_BOX_NAME='chef/centos-6.5' vagrant up # for test with Centos
205+
206+
You can change the VM used during test by setting the `VAGRANT_BOX_NAME` env
207+
variable to something else than `deb/jessie`.
208+
209+
## License
210+
211+
BSD

defaults/main.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
# ################
3+
# Playbook control
4+
# ################
5+
6+
# Take the package given by the OS/distrib
7+
rabbitmq_os_package : false
8+
9+
# Plugins
10+
rabbitmq_plugins : []
11+
rabbitmq_new_only : 'no'
12+
13+
# VHOST
14+
rabbitmq_vhost_definitions : []
15+
rabbitmq_users_definitions : []
16+
17+
# Avoid setting up federation
18+
rabbitmq_federation : false
19+
20+
# defaults file for rabbitmq
21+
rabbitmq_cacert : "files/rabbitmq_cacert.pem"
22+
rabbitmq_server_key : "files/rabbitmq_server_key.pem"
23+
rabbitmq_server_cert : "files/rabbitmq_server_cert.pem"
24+
rabbitmq_ssl : true
25+
26+
## Optional logging
27+
## none, error, warnings, info, debug
28+
# rabbitmq_log_level :
29+
# channel : error
30+
# connection : error
31+
# federation : error
32+
# mirroring : error
33+
34+
# ######################
35+
# RabbitMQ Configuration
36+
# ######################
37+
38+
# rabbitmq TCP configuration
39+
rabbitmq_conf_tcp_listeners_address : '0.0.0.0'
40+
rabbitmq_conf_tcp_listeners_port : 5672
41+
42+
# rabbitmq SSL configuration
43+
rabbitmq_conf_ssl_listeners_address : '0.0.0.0'
44+
rabbitmq_conf_ssl_listeners_port : 5671
45+
rabbitmq_conf_ssl_options_cacertfile : "/etc/rabbitmq/ssl/{{ rabbitmq_cacert | basename }}"
46+
rabbitmq_conf_ssl_options_certfile : "/etc/rabbitmq/ssl/{{ rabbitmq_server_cert | basename }}"
47+
rabbitmq_conf_ssl_options_keyfile : "/etc/rabbitmq/ssl/{{ rabbitmq_server_key | basename }}"
48+
rabbitmq_conf_ssl_options_fail_if_no_peer_cert: "true"
49+
50+
rabbitmq_env : false
51+
# Guest options
52+
remove_guest_user : true
53+
54+
# Enable cluster
55+
rabbitmq_clustering : false
56+
## Erlang cookie
57+
rabbitmq_erlang_cookie_path : "/var/lib/rabbitmq/.erlang.cookie"
58+
rabbitmq_erlang_cookie : beKSqkmoLrtvVfjOytLOQpATbGVEGbVA #test cookie, override for production
59+
## Cluster options
60+
rabbitmq_cluster_instance_to_join_index : 0
61+
rabbitmq_cluster_instance_to_join : "{{ groups[rabbitmq_cluster_group][rabbitmq_cluster_instance_to_join_index].split('.')[0] }}"
62+
rabbitmq_cluster_group : rabbit_cluster
63+
rabbitmq_cluster_post_fix_domain : "production.example.com"
64+
# Automation user for cluster. You should encrypt
65+
rabbitmq_cluster_api_user : "api-automation"
66+
rabbitmq_cluster_api_password : "api-password"
67+
68+
# How to get the IPs of cluster
69+
rabbitmq_clustering_resolve_names : "ansible" # ['ansible', dns]
70+
71+
## Probably dont need to change that stuff
72+
### Construct a regex to match group before .
73+
rabbitmq_cluster_post_fix_domain_regex_replace: "([^.]*).*"
74+
# Print extra message related to inventory
75+
rabbitmq_cluster_debug : false
76+

files/rabbitmq.list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Official repository of rabbitmq
2+
deb http://www.rabbitmq.com/debian/ testing main

handlers/main.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
# handlers file for rabbitmq
3+
- name: restart rabbitmq-server
4+
service: name=rabbitmq-server state=restarted enabled=yes
5+
6+
- name: stop rabbitmq-server
7+
service: name=rabbitmq-server state=stopped enabled=yes
8+
9+
- name: start rabbitmq-server
10+
service: name=rabbitmq-server state=started enabled=yes

0 commit comments

Comments
 (0)