From c9559630c6b58400410b47ba3aa4807b5369110d Mon Sep 17 00:00:00 2001 From: wenchma Date: Thu, 7 Aug 2014 16:27:42 +0800 Subject: [PATCH] Fix the conflict configuration on rabbitmq port In current logic, rabbitmq port will be set to ssl-listening port, this will make rabbitmq fail to start. This submit will configure rabbitmq port for both ssl and non-ssl cases. Closes-Bug: #1353884 Change-Id: I37dc9b656c553554b9bc636fe35c69744debe92a --- CHANGELOG.md | 3 +++ README.md | 1 + metadata.rb | 4 ++-- recipes/rabbitmq-server.rb | 10 +++++++++- spec/rabbitmq-server_spec.rb | 16 ++++++++++++++++ 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 053f020..bd35d7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ This file is used to list changes made in each version of cookbook-openstack-ops-messaging. +## 10.0.1 +* Configure rabbitmq port for both ssl and non-ssl cases + ## 10.0.0 * Upgrading to Juno * Upgrading berkshelf from 2.0.18 to 3.1.5 diff --git a/README.md b/README.md index fd6e833..80fb122 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ The following attributes are defined in attributes/messaging.rb of the common co * `openstack["endpoints"]["mq"]["port"]` - The port to bind the rabbit service to * `openstack["endpoints"]["mq"]["path"]` - Unused at this time * `openstack["endpoints"]["mq"]["bind_interface"]` - The interface name to bind the rabbit service to +* `openstack["mq"]["rabbitmq"]["use_ssl"]` - Enables/disables SSL for RabbitMQ, the default is false. If the value of the "bind_interface" attribute is non-nil, then the rabbit service will be bound to the first IP address on that interface. If the value of the "bind_interface" attribute is nil, then the rabbit service will be bound to the IP address specified in the host attribute. diff --git a/metadata.rb b/metadata.rb index 694f8f2..36e4595 100644 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer 'Chef Software, Inc.' maintainer_email 'matt@getchef.com' license 'Apache 2.0' description 'Provides the shared messaging configuration for Chef for OpenStack.' -version '10.0.0' +version '10.0.1' recipe 'server', 'Installs and configures server packages for messaging queue used by the deployment.' recipe 'rabbitmq-server', 'Installs and configures RabbitMQ and is called via the server recipe' @@ -13,5 +13,5 @@ recipe 'rabbitmq-server', 'Installs and configures RabbitMQ and is called via th supports os end -depends 'openstack-common', '~> 10.0' +depends 'openstack-common', '~> 10.0.1' depends 'rabbitmq', '>= 3.0.4' diff --git a/recipes/rabbitmq-server.rb b/recipes/rabbitmq-server.rb index 11fa934..84fa7e4 100644 --- a/recipes/rabbitmq-server.rb +++ b/recipes/rabbitmq-server.rb @@ -33,7 +33,15 @@ listen_address = rabbit_endpoint.host # Used by OpenStack#rabbit_servers/#rabbit_server node.set['openstack']['mq']['listen'] = listen_address -node.override['rabbitmq']['port'] = rabbit_endpoint.port +if node['openstack']['mq']['rabbitmq']['use_ssl'] + if node['rabbitmq']['ssl_port'] != rabbit_endpoint.port + node.override['rabbitmq']['port'] = rabbit_endpoint.port + else + Chef::Log.error 'Unable to listen on the port #{rabbit_endpoint.port} for RabbitMQ TCP, which is listened on by SSL!' + end +else + node.override['rabbitmq']['port'] = rabbit_endpoint.port +end node.override['rabbitmq']['address'] = listen_address node.override['rabbitmq']['default_user'] = user node.override['rabbitmq']['default_pass'] = pass diff --git a/spec/rabbitmq-server_spec.rb b/spec/rabbitmq-server_spec.rb index 9b6ddb0..c2c30a5 100644 --- a/spec/rabbitmq-server_spec.rb +++ b/spec/rabbitmq-server_spec.rb @@ -12,6 +12,8 @@ describe 'openstack-ops-messaging::rabbitmq-server' do it 'overrides default rabbit attributes' do expect(chef_run.node['openstack']['endpoints']['mq']['port']).to eq('5672') expect(chef_run.node['openstack']['mq']['listen']).to eq('127.0.0.1') + expect(chef_run.node['openstack']['mq']['rabbitmq']['use_ssl']).to be_falsey + expect(chef_run.node['rabbitmq']['port']).to eq(5672) expect(chef_run.node['rabbitmq']['address']).to eq('127.0.0.1') expect(chef_run.node['rabbitmq']['default_user']).to eq('guest') expect(chef_run.node['rabbitmq']['default_pass']).to eq('rabbit-pass') @@ -33,6 +35,20 @@ describe 'openstack-ops-messaging::rabbitmq-server' do expect(chef_run.node['openstack']['mq']['image']['rabbit']['vhost']).to eq('/bar') end + describe 'rabbit ssl' do + before do + node.set['openstack']['mq']['rabbitmq']['use_ssl'] = true + end + + it 'overrides rabbit ssl attributes' do + node.set['openstack']['endpoints']['mq']['port'] = '5671' + + expect(chef_run.node['openstack']['mq']['rabbitmq']['use_ssl']).to be_truthy + expect(chef_run.node['rabbitmq']['ssl_port']).to eq(5671) + expect(chef_run.node['rabbitmq']['port']).to be_nil + end + end + describe 'cluster' do before do node.set['openstack']['mq'] = {