Skip to content

Commit cd51d4a

Browse files
authored
Merge pull request #5 from hellofresh/feature/ssl
Improve TLS configuration
2 parents 24b2dcc + db81e25 commit cd51d4a

File tree

8 files changed

+24
-10
lines changed

8 files changed

+24
-10
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ language: python
33
python: "2.7"
44
before_install:
55
- sudo apt-get update -qq
6+
- sudo apt-get purge rabbitmq-server
67
install:
78
# Install Ansible.
8-
- pip install ansible
9+
- pip install ansible==2.3.2.0
910

1011
# Create an inventory file for testing.
1112
- "printf 'rabbit-standalone ansible_ssh_host=localhost' > inventory"

defaults/main.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ rabbitmq_server_key : "files/rabbitmq_server_key.pem"
2323
rabbitmq_server_cert : "files/rabbitmq_server_cert.pem"
2424
rabbitmq_ssl : true
2525

26+
# SSL Configuration
27+
rabbitmq_copy_ssl_files : true
28+
rabbitmq_use_ssl_cn_as_login : false
29+
30+
# Authentication mechanisms (not set by default)
31+
# rabbitmq_auth_mechanisms : [ 'PLAIN', 'AMQPLAIN' ]
32+
2633
## Optional logging
2734
## none, error, warnings, info, debug
2835
# rabbitmq_log_level :

tasks/configuration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
group="rabbitmq"
88
mode=0750
99
state="directory"
10-
when: rabbitmq_ssl
10+
when: rabbitmq_ssl and rabbitmq_copy_ssl_files
1111

1212
- name: configuration | copy the ssl certificates
1313
copy:
@@ -24,7 +24,7 @@
2424
dest: "{{ rabbitmq_conf_ssl_options_keyfile }}"
2525
- src: "{{ rabbitmq_server_cert }}"
2626
dest: "{{ rabbitmq_conf_ssl_options_certfile }}"
27-
when: rabbitmq_ssl
27+
when: rabbitmq_ssl and rabbitmq_copy_ssl_files
2828

2929
- name: configuration | generate the configuration of rabbitmq
3030
template:

tasks/federation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@
1717
name={{ item.name }}
1818
vhost={{ item.vhost | default('/', false) }}
1919
value=" {{ item.value }} "
20-
with_items: rabbitmq_federation_configuration
20+
with_items: "{{rabbitmq_federation_configuration}}"
2121

2222
- name: get the version of rabbitmq
2323
shell: rabbitmqctl status | awk '{print $NF}'
2424
register: rabbitmq_version
25+
changed_when: False
2526

2627
# local-username is no longer required with 3.3.0
2728
# http://www.rabbitmq.com/release-notes/README-3.3.0.txt

tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010

1111
- include: users.yml
1212

13-
- include: policy.yml
14-
when: "rabbitmq_policy_configuration is defined"
15-
1613
- include: federation.yml
1714
when: rabbitmq_federation
1815

16+
- include: policy.yml
17+
when: "rabbitmq_policy_configuration is defined"
18+
1919
- block:
2020
- include: cluster/checks.yml
2121
- include: cluster/hostnames.yml

templates/rabbitmq.config.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@
2424
{tcp_listeners, []}{% if rabbitmq_ssl %},
2525
{% endif %}
2626
{% endif %}
27+
{% if rabbitmq_auth_mechanisms is defined %}
28+
{auth_mechanisms, [ {% for authmech in rabbitmq_auth_mechanisms %}'{{authmech}}'{% if not loop.last %},{% endif %}{% endfor %} ]},
29+
{% endif %}
30+
{% if rabbitmq_use_ssl_cn_as_login %}
31+
{ssl_cert_login_from, common_name},
32+
{% endif %}
2733
{% if rabbitmq_ssl %}
2834
{ssl_listeners, [{"{{ rabbitmq_conf_ssl_listeners_address }}", {{ rabbitmq_conf_ssl_listeners_port }}}]},
2935
{ssl_options, [

test/integration/cluster_1/cluster_1.retry

Lines changed: 0 additions & 1 deletion
This file was deleted.

vagrant/test_standalone.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
- shell: netstat -an | grep 0.0.0.0:5672.*LISTEN
33
register: test_result
44
ignore_errors: True
5-
- name: rabbitmq should not be listenning to the unencrypted port
5+
- name: rabbitmq should be listenning to the unencrypted port
66
assert:
77
that:
8-
- test_result|failed
8+
- test_result|success
99

1010
- shell: netstat -an | grep 0.0.0.0:5671.*LISTEN
1111
register: test_result

0 commit comments

Comments
 (0)