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:
repositories:
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile.git'
'concat': 'git://github.com/puppetlabs/puppetlabs-concat.git'
'keystone': 'git://github.com/stackforge/puppet-keystone.git'
'mysql': 'git://github.com/puppetlabs/puppetlabs-mysql.git'
'openstacklib': 'git://github.com/stackforge/puppet-openstacklib.git'
'postgresql':
repo: 'git://github.com/puppetlabs/puppet-postgresql.git'
ref: '2.5.0'
'postgresql': 'git://github.com/puppetlabs/puppet-postgresql.git'
'stdlib': 'git://github.com/puppetlabs/puppetlabs-stdlib.git'
symlinks:
'tuskar': "#{source_dir}"

View File

@ -1,36 +1,47 @@
# == Class: tuskar::db::postgresql
#
# Manage the tuskar postgresql database
# Class that configures postgresql for tuskar
# Requires the Puppetlabs postgresql module.
#
# === Parameters:
#
# [*password*]
# (required) Password that will be used for the tuskar db user.
# (Required) Password to connect to the database.
#
# [*dbname*]
# (optionnal) Name of tuskar database.
# Defaults to tuskar
# (Optional) Name of the database.
# Defaults to 'tuskar'.
#
# [*user*]
# (optionnal) Name of tuskar user.
# Defaults to tuskar
# (Optional) User to connect to the database.
# 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(
$password,
$dbname = 'tuskar',
$user = 'tuskar'
$dbname = 'tuskar',
$user = 'tuskar',
$encoding = undef,
$privileges = 'ALL',
) {
require postgresql::python
Class['tuskar::db::postgresql'] -> Service<| title == 'tuskar' |>
Postgresql::Db[$dbname] ~> Exec<| title == 'tuskar-dbsync' |>
Package['python-psycopg2'] -> Exec<| title == 'tuskar-dbsync' |>
postgresql::db { $dbname:
user => $user,
password => $password,
::openstacklib::db::postgresql { 'tuskar':
password_hash => postgresql_password($user, $password),
dbname => $dbname,
user => $user,
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
let :req_params do
{:password => 'pw'}
{ :password => 'pw' }
end
let :facts do
{
:postgres_default_version => '8.4',
:osfamily => 'RedHat',
}
let :pre_condition do
'include postgresql::server'
end
describe 'with only required params' do
let :params do
req_params
context 'on a RedHat osfamily' do
let :facts do
{
:osfamily => 'RedHat',
:operatingsystemrelease => '7.0',
:concat_basedir => '/var/lib/puppet/concat'
}
end
it { is_expected.to contain_postgresql__db('tuskar').with(
:user => 'tuskar',
:password => 'pw'
) }
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
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