Merge "Migrate postgresql backend to use openstacklib::db::postgresql"

This commit is contained in:
Jenkins 2015-04-12 18:21:57 +00:00 committed by Gerrit Code Review
commit 8c28b3a40f
3 changed files with 74 additions and 32 deletions

View File

@ -1,12 +1,11 @@
fixtures: fixtures:
repositories: repositories:
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile.git' 'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile.git'
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'keystone': 'git://github.com/stackforge/puppet-keystone.git' 'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'mysql': 'git://github.com/puppetlabs/puppetlabs-mysql.git' 'mysql': 'git://github.com/puppetlabs/puppetlabs-mysql.git'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git' 'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'postgresql': 'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git'
repo: 'git://github.com/puppetlabs/puppet-postgresql.git'
ref: '2.5.0'
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git' 'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
symlinks: symlinks:
'tuskar': "#{source_dir}" 'tuskar': "#{source_dir}"

View File

@ -1,36 +1,47 @@
# == Class: tuskar::db::postgresql # == Class: tuskar::db::postgresql
# #
# Manage the tuskar postgresql database # Class that configures postgresql for tuskar
# Requires the Puppetlabs postgresql module.
# #
# === Parameters: # === Parameters:
# #
# [*password*] # [*password*]
# (required) Password that will be used for the tuskar db user. # (Required) Password to connect to the database.
# #
# [*dbname*] # [*dbname*]
# (optionnal) Name of tuskar database. # (Optional) Name of the database.
# Defaults to tuskar # Defaults to 'tuskar'.
# #
# [*user*] # [*user*]
# (optionnal) Name of tuskar user. # (Optional) User to connect to the database.
# Defaults to tuskar # Defaults to 'tuskar'.
#
# [*encoding*]
# (Optional) The charset to use for the database.
# Default to undef.
#
# [*privileges*]
# (Optional) Privileges given to the database user.
# Default to 'ALL'
# #
class tuskar::db::postgresql( class tuskar::db::postgresql(
$password, $password,
$dbname = 'tuskar', $dbname = 'tuskar',
$user = 'tuskar' $user = 'tuskar',
$encoding = undef,
$privileges = 'ALL',
) { ) {
require postgresql::python
Class['tuskar::db::postgresql'] -> Service<| title == 'tuskar' |> Class['tuskar::db::postgresql'] -> Service<| title == 'tuskar' |>
Postgresql::Db[$dbname] ~> Exec<| title == 'tuskar-dbsync' |>
Package['python-psycopg2'] -> Exec<| title == 'tuskar-dbsync' |>
::openstacklib::db::postgresql { 'tuskar':
postgresql::db { $dbname: password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user, user => $user,
password => $password, encoding => $encoding,
privileges => $privileges,
} }
::Openstacklib::Db::Postgresql['tuskar'] ~> Exec<| title == 'tuskar-dbsync' |>
} }

View File

@ -3,24 +3,56 @@ require 'spec_helper'
describe 'tuskar::db::postgresql' do describe 'tuskar::db::postgresql' do
let :req_params do let :req_params do
{:password => 'pw'} { :password => 'pw' }
end end
let :pre_condition do
'include postgresql::server'
end
context 'on a RedHat osfamily' do
let :facts do let :facts do
{ {
:postgres_default_version => '8.4',
:osfamily => 'RedHat', :osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
} }
end end
describe 'with only required params' do context 'with only required parameters' do
let :params do let :params do
req_params req_params
end end
it { is_expected.to contain_postgresql__db('tuskar').with(
it { should contain_postgresql__server__db('tuskar').with(
:user => 'tuskar', :user => 'tuskar',
:password => 'pw' :password => 'md532cc9d9d42efb508bc9d6267d873d63d'
) } )}
end
end
context 'on a Debian osfamily' do
let :facts do
{
:operatingsystemrelease => '7.8',
:operatingsystem => 'Debian',
:osfamily => 'Debian',
:concat_basedir => '/var/lib/puppet/concat'
}
end
context 'with only required parameters' do
let :params do
req_params
end
it { should contain_postgresql__server__db('tuskar').with(
:user => 'tuskar',
:password => 'md532cc9d9d42efb508bc9d6267d873d63d'
)}
end
end end
end end