Permalink
Browse files

Add swift to keystone class

This commit adds keystone auth objects to the
openstack::keystone class. This allows users to
easily add a swift services auth user to their
existing keystone servers. It is not enabled by
default.
  • Loading branch information...
1 parent b44e240 commit 1fe95ffb068fe4e6b213c98f5fdd839850d298aa Dan Bode committed Jan 12, 2013
Showing with 96 additions and 0 deletions.
  1. +1 −0 .fixtures.yml
  2. +34 −0 manifests/keystone.pp
  3. +61 −0 spec/classes/openstack_keystone_spec.rb
View
@@ -16,5 +16,6 @@ fixtures:
'inifile': 'git://github.com/cprice-puppet/puppetlabs-inifile'
"create_resources": 'git://github.com/puppetlabs/puppetlabs-create_resources'
'vswitch': 'git://github.com/ekarlso/puppet-vswitch'
+ 'swift' : 'git://github.com/puppetlabs/puppetlabs-swift'
symlinks:
"openstack": "#{source_dir}"
View
@@ -23,6 +23,7 @@
# [admin_address] Keystone admin address. Optional. Defaults to $internal_address
# [glance] Set up glance endpoints and auth. Optional. Defaults to true
# [nova] Set up nova endpoints and auth. Optional. Defaults to true
+# [swift] Set up swift endpoints and auth. Optional. Defaults to false
# [enabled] If the service is active (true) or passive (false).
# Optional. Defaults to true
#
@@ -47,6 +48,7 @@
$nova_user_password,
$cinder_user_password,
$quantum_user_password,
+ $swift_user_password = false,
$public_address,
$db_type = 'mysql',
$db_user = 'keystone',
@@ -69,10 +71,14 @@
$quantum_public_address = false,
$quantum_internal_address = false,
$quantum_admin_address = false,
+ $swift_public_address = false,
+ $swift_internal_address = false,
+ $swift_admin_address = false,
$glance = true,
$nova = true,
$cinder = true,
$quantum = true,
+ $swift = false,
$enabled = true
) {
@@ -155,6 +161,21 @@
} else {
$quantum_admin_real = $quantum_internal_real
}
+ if($swift_public_address) {
+ $swift_public_real = $swift_public_address
+ } else {
+ $swift_public_real = $public_address
+ }
+ if($swift_internal_address) {
+ $swift_internal_real = $swift_internal_address
+ } else {
+ $swift_internal_real = $swift_public_real
+ }
+ if($swift_admin_address) {
+ $swift_admin_real = $swift_admin_address
+ } else {
+ $swift_admin_real = $swift_internal_real
+ }
class { '::keystone':
verbose => $verbose,
@@ -222,6 +243,19 @@
region => $region,
}
}
+
+ if $swift {
+
+ if ! $swift_user_password {
+ fail('Must set a swift_user_password when swift auth is being configured')
+ }
+
+ class { 'swift::keystone::auth':
+ password => $swift_user_password,
+ address => $swift_public_real,
+ region => $region,
+ }
+ }
}
}
@@ -0,0 +1,61 @@
+require 'spec_helper'
+
+describe 'openstack::keystone' do
+ # minimum set of default parameters
+ let :default_params do
+ {
+ :db_host => '127.0.0.1',
+ :db_password => 'pass',
+ :admin_token => 'token',
+ :admin_email => 'email@address.com',
+ :admin_password => 'pass',
+ :glance_user_password => 'pass',
+ :nova_user_password => 'pass',
+ :cinder_user_password => 'pass',
+ :quantum_user_password => 'pass',
+ :swift_user_password => false,
+ :public_address => '127.0.0.1',
+ }
+ end
+
+ let :facts do
+ {
+ :operatingsystem => 'Ubuntu',
+ :osfamily => 'Debian',
+ }
+ end
+
+ let :params do
+ default_params
+ end
+
+ describe 'without swift' do
+ it { should_not contain_class('swift::keystone::auth') }
+ end
+
+ describe 'swift' do
+ describe 'without password' do
+ let :params do
+ default_params.merge(:swift => true)
+ end
+ it 'should fail when the password is not set' do
+ expect do
+ subject
+ end.to raise_error(Puppet::Error)
+ end
+ end
+ describe 'with password' do
+ let :params do
+ default_params.merge(:swift => true, :swift_user_password => 'dude')
+ end
+ it do
+ should contain_class('swift::keystone::auth').with(
+ :password => 'dude',
+ :address => '127.0.0.1',
+ :region => 'RegionOne'
+ )
+ end
+ end
+ end
+
+end

0 comments on commit 1fe95ff

Please sign in to comment.