-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update openstacklib to latest master
- 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
Showing
5 changed files
with
212 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
openstacklib/spec/defines/openstacklib_messaging_rabbitmq_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |