Skip to content

Commit

Permalink
Update openstacklib to latest master
Browse files Browse the repository at this point in the history
- old commit: bfbe779b17a9d53b26f1d246d35d44b29637f0ce
- new commit: 2fc2e5504de7c298263a1d63af92974a7779d5c9

commit 2fc2e5504de7c298263a1d63af92974a7779d5c9
Author: Emilien Macchi <[email protected]>
Date:   Fri Nov 14 13:37:09 2014 +0100

    Implement openstacklib::messaging::rabbitmq

    * Add puppetlabs-rabbitmq 4.x as a dependency in fixtures &
      metadata.json
    * Implement openstacklib::messaging::rabbitmq to manage user, permissions
      and vhost in RabbitMQ (+ unit tests)
    * Documentation

    Change-Id: I65190035b51f3d72e4302dae7fad92a280d63cff
  • Loading branch information
xbezdick committed Nov 18, 2014
1 parent 12861ad commit 4e16da6
Show file tree
Hide file tree
Showing 5 changed files with 212 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Puppetfile
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ mod 'openstack',
:git => 'https://github.com/stackforge/puppet-openstack.git'

mod 'openstacklib',
:commit => 'bfbe779b17a9d53b26f1d246d35d44b29637f0ce',
:commit => '2fc2e5504de7c298263a1d63af92974a7779d5c9',
:git => 'https://github.com/stackforge/puppet-openstacklib.git'

mod 'pacemaker',
Expand Down
3 changes: 3 additions & 0 deletions openstacklib/.fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ fixtures:
aviator: git://github.com/aimonb/puppet_aviator.git
mysql: git://github.com/puppetlabs/puppetlabs-mysql.git
stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git
rabbitmq:
repo: 'git://github.com/puppetlabs/puppetlabs-rabbitmq'
ref: 'origin/4.x'
symlinks:
'openstacklib': "#{source_dir}"
105 changes: 105 additions & 0 deletions openstacklib/manifests/messaging/rabbitmq.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#
# Copyright (C) 2014 eNovance SAS <[email protected]>
#
# Author: Emilien Macchi <[email protected]>
#
# 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.
#
# == Definition: openstacklib::messaging::rabbitmq
#
# This resource creates RabbitMQ resources for an OpenStack service.
#
# == Parameters:
#
# [*userid*]
# (optional) The username to use when connecting to Rabbit
# Defaults to 'guest'
#
# [*password*]
# (optional) The password to use when connecting to Rabbit
# Defaults to 'guest'
#
# [*virtual_host*]
# (optional) The virtual host to use when connecting to Rabbit
# Defaults to '/'
#
# [*is_admin*]
# (optional) If the user should be admin or not
# Defaults to false
#
# [*configure_permission*]
# (optional) Define configure permission
# Defaults to '.*'
#
# [*write_permission*]
# (optional) Define write permission
# Defaults to '.*'
#
# [*read_permission*]
# (optional) Define read permission
# Defaults to '.*'
#
# [*manage_user*]
# (optional) Manage or not the user
# Defaults to true
#
# [*manage_user_permissions*]
# (optional) Manage or not user permissions
# Defaults to true
#
# [*manage_vhost*]
# (optional) Manage or not the vhost
# Defaults to true
#
define openstacklib::messaging::rabbitmq(
$userid = 'guest',
$password = 'guest',
$virtual_host = '/',
$is_admin = false,
$configure_permission = '.*',
$write_permission = '.*',
$read_permission = '.*',
$manage_user = true,
$manage_user_permissions = true,
$manage_vhost = true,
) {

if $manage_user {
if $userid == 'guest' {
$is_admin_real = false
} else {
$is_admin_real = $is_admin
}
ensure_resource('rabbitmq_user', $userid, {
'admin' => $is_admin_real,
'password' => $password,
'provider' => 'rabbitmqctl',
})
}

if $manage_user_permissions {
ensure_resource('rabbitmq_user_permissions', "${userid}@${virtual_host}", {
'configure_permission' => $configure_permission,
'write_permission' => $write_permission,
'read_permission' => $read_permission,
'provider' => 'rabbitmqctl',
})
}

if $manage_vhost {
ensure_resource('rabbitmq_vhost', $virtual_host, {
'provider' => 'rabbitmqctl',
})
}

}
3 changes: 2 additions & 1 deletion openstacklib/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"dependencies": [
{ "name": "aimonb/aviator", "version_requirement": ">=0.4.2 <1.0.0" },
{ "name": "puppetlabs/mysql", "version_requirement": ">=2.2.0 <3.0.0" },
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" }
{ "name": "puppetlabs/stdlib", "version_requirement": ">=4.0.0 <5.0.0" },
{ "name": "puppetlabs/rabbitmq", "version_requirement": ">=4.0.0 <5.0.0" }
]
}
101 changes: 101 additions & 0 deletions openstacklib/spec/defines/openstacklib_messaging_rabbitmq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#
# Copyright (C) 2014 eNovance SAS <[email protected]>
#
# Author: Emilien Macchi <[email protected]>
#
# 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.

require 'spec_helper'

describe 'openstacklib::messaging::rabbitmq' do

let (:title) { 'nova' }

shared_examples 'openstacklib::messaging::rabbitmq examples' do

let :params do
{}
end

context 'with default parameters' do
it { should contain_rabbitmq_user('guest').with(
:admin => false,
:password => 'guest',
:provider => 'rabbitmqctl',
)}
it { should contain_rabbitmq_user_permissions('guest@/').with(
:configure_permission => '.*',
:write_permission => '.*',
:read_permission => '.*',
:provider => 'rabbitmqctl',
)}
it { should contain_rabbitmq_vhost('/').with(
:provider => 'rabbitmqctl',
)}
end

context 'with custom parameters' do
before :each do
params.merge!(
:userid => 'nova',
:password => 'secrete',
:virtual_host => '/nova',
:is_admin => true,
:configure_permission => '.nova',
:write_permission => '.nova',
:read_permission => '.nova'
)
end

it { should contain_rabbitmq_user('nova').with(
:admin => true,
:password => 'secrete',
:provider => 'rabbitmqctl',
)}
it { should contain_rabbitmq_user_permissions('nova@/nova').with(
:configure_permission => '.nova',
:write_permission => '.nova',
:read_permission => '.nova',
:provider => 'rabbitmqctl',
)}
it { should contain_rabbitmq_vhost('/nova').with(
:provider => 'rabbitmqctl',
)}
end

context 'when disabling vhost management' do
before :each do
params.merge!( :manage_vhost => false )
end

it { should_not contain_rabbitmq_vhost }
end

end

context 'on a Debian osfamily' do
let :facts do
{ :osfamily => "Debian" }
end

include_examples 'openstacklib::messaging::rabbitmq examples'
end

context 'on a RedHat osfamily' do
let :facts do
{ :osfamily => 'RedHat' }
end

include_examples 'openstacklib::messaging::rabbitmq examples'
end
end

0 comments on commit 4e16da6

Please sign in to comment.