adaptions to work with refactored cookbooks

* adapted rabbitmq-server recipe to fit new endpoint logic
* removed unneeded server recipe
* fixed typo in rabbitmq-server recipe (port -> ssl_port) attribute
* adapted specs to properly check for ssl configuration

Depends-On: I0547182085eed91d05384fdd7734408a839a9a2c
Implements: blueprint cookbook-refactoring
Change-Id: I80ed8a7892b59f7fd582505445a31b0df8d68752
This commit is contained in:
Jan Klare 2016-01-26 18:08:04 +01:00
parent 4cbc897422
commit 1e0a81aecd
8 changed files with 27 additions and 98 deletions

View File

@ -1,5 +1,6 @@
# This configuration was generated by `rubocop --auto-gen-config`
# on 2015-05-29 12:05:34 -0500 using RuboCop version 0.29.1.
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-02-04 17:44:50 +0100 using RuboCop version 0.34.2.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
@ -8,4 +9,11 @@
# Offense count: 1
# Configuration parameters: EnforcedStyle, SupportedStyles.
Style/ClassAndModuleChildren:
Enabled: false
Exclude:
- 'recipes/rabbitmq-server.rb'
# Offense count: 1
# Configuration parameters: Exclude.
Style/Documentation:
Exclude:
- 'recipes/rabbitmq-server.rb'

14
Gemfile
View File

@ -1,14 +0,0 @@
## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE
## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE
## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS
source 'https://rubygems.org'
gem 'chef', '~> 11.18.6'
gem 'json', '<= 1.7.7' # chef 11 dependency
gem 'berkshelf', '~> 3.2.1'
gem 'hashie', '~> 2.0'
gem 'chefspec', '~> 4.0.0'
gem 'rspec', '~> 3.0.0'
gem 'foodcritic', '~> 4.0'
gem 'rubocop', '~> 0.29.1'

View File

@ -4,14 +4,14 @@ maintainer 'openstack-chef'
maintainer_email 'openstack-dev@lists.openstack.org'
license 'Apache 2.0'
description 'Provides the shared messaging configuration for Chef for OpenStack.'
version '12.0.0'
version '13.0.0'
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'
%w(fedora ubuntu redhat centos suse).each do |os|
%w(ubuntu redhat centos).each do |os|
supports os
end
depends 'openstack-common', '>= 12.0.0'
depends 'openstack-common', '>= 13.0.0'
depends 'rabbitmq', '~> 4.1'

View File

@ -20,22 +20,26 @@
# limitations under the License.
#
class ::Chef::Recipe # rubocop:disable Documentation
class ::Chef::Recipe
include ::Openstack
end
user = node['openstack']['mq']['user']
pass = get_password 'user', user
vhost = node['openstack']['mq']['vhost']
rabbit_endpoint = endpoint 'mq'
listen_address = rabbit_endpoint.host
rabbit_endpoint = node['openstack']['endpoints']['mq']
bind_interface = rabbit_endpoint.bind_interface
if bind_interface
listen_address = address_for bind_interface
else
listen_address = rabbit_endpoint.host
end
# Used by OpenStack#rabbit_servers/#rabbit_server
node.set['openstack']['mq']['listen'] = listen_address
if node['openstack']['mq']['rabbitmq']['use_ssl']
if node['rabbitmq']['ssl_port'] != rabbit_endpoint.port
node.override['rabbitmq']['port'] = rabbit_endpoint.port
node.override['rabbitmq']['ssl_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
@ -64,27 +68,23 @@ include_recipe 'rabbitmq::mgmt_console'
rabbitmq_user 'remove rabbit guest user' do
user 'guest'
action :delete
not_if { user == 'guest' }
end
rabbitmq_user 'add openstack rabbit user' do
user user
password pass
action :add
end
rabbitmq_user 'change openstack rabbit user password' do
user user
password pass
action :change_password
end
rabbitmq_vhost 'add openstack rabbit vhost' do
vhost vhost
action :add
end
@ -99,14 +99,5 @@ end
rabbitmq_user 'set rabbit administrator tag' do
user user
tag 'administrator'
action :set_tags
end
# TODO(wenchma) This could be removed once the issue is fixed in rabbitmq cookbook.
# Issue: https://github.com/kennonkwok/rabbitmq/issues/153
# Notifies rabbitmq-server service restart.
r = resources(template: "#{node['rabbitmq']['config_root']}/rabbitmq-env.conf")
r.notifies(:restart, "service[#{node['rabbitmq']['service_name']}]", :immediately)
r = resources(template: "#{node['rabbitmq']['config_root']}/rabbitmq.config")
r.notifies(:restart, "service[#{node['rabbitmq']['service_name']}]", :immediately)

View File

@ -1,23 +0,0 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-ops-messaging
# Recipe:: server
#
# Copyright 2013, Opscode, Inc.
# Copyright 2013, Craig Tracey <craigtracey@gmail.com>
# Copyright 2013, AT&T Services, Inc.
#
# Licensed under the Apache License, Version 2.0 (the 'License');
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an 'AS IS' BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "openstack-ops-messaging::#{node['openstack']['mq']['service_type']}-server"

View File

@ -4,7 +4,7 @@ require_relative 'spec_helper'
describe 'openstack-ops-messaging::rabbitmq-server' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'ops_messaging_stubs'

View File

@ -13,7 +13,7 @@ describe 'openstack-ops-messaging::rabbitmq-server' 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']['port']).to eq('5672')
expect(chef_run.node['rabbitmq']['address']).to eq('127.0.0.1')
expect(chef_run.node['rabbitmq']['use_distro_version']).to be_truthy
end
@ -36,13 +36,12 @@ describe 'openstack-ops-messaging::rabbitmq-server' do
describe 'rabbit ssl' do
before do
node.set['openstack']['mq']['rabbitmq']['use_ssl'] = true
node.set['openstack']['endpoints']['mq']['port'] = '1234'
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']['ssl_port']).to eq('1234')
expect(chef_run.node['rabbitmq']['port']).to be_nil
end
end
@ -129,22 +128,6 @@ describe 'openstack-ops-messaging::rabbitmq-server' do
'set rabbit administrator tag'
).with(user: 'not-a-guest', tag: 'administrator')
end
describe 'template rabbitmq-env.conf notifies immediately' do
let(:template) { chef_run.template('/etc/rabbitmq/rabbitmq-env.conf') }
it 'sends the specific notification to the service immediately' do
expect(template).to notify('service[rabbitmq-server]').to(:restart).immediately
end
end
describe 'notifies immediately' do
let(:template) { chef_run.template('/etc/rabbitmq/rabbitmq.config') }
it 'sends the specific notification to the service immediately' do
expect(template).to notify('service[rabbitmq-server]').to(:restart).immediately
end
end
end
end
end

View File

@ -1,16 +0,0 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-ops-messaging::server' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
include_context 'ops_messaging_stubs'
it 'uses proper messaging server recipe' do
expect(chef_run).to include_recipe 'openstack-ops-messaging::rabbitmq-server'
end
end
end