Migrate postgresql backend to use openstacklib::db::postgresql
Let migrate to the new openstacklib::db::postgresql helper for postgresql backend. This commit also unpin postgresql fixture (openstacklib support now the latest version of postgre module). Change-Id: I9bf307d758c112a9b458dab3dfba26281278e38f Implements: blueprint commmon-openstack-database-resource
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
'inifile': 'git://github.com/puppetlabs/puppetlabs-inifile'
|
||||
'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:
|
||||
'trove': "#{source_dir}"
|
||||
|
@@ -1,36 +1,47 @@
|
||||
# == Class: trove::db::postgresql
|
||||
#
|
||||
# Manage the trove postgresql database
|
||||
# Class that configures postgresql for trove
|
||||
# Requires the Puppetlabs postgresql module.
|
||||
#
|
||||
# === Parameters:
|
||||
# === Parameters
|
||||
#
|
||||
# [*password*]
|
||||
# (required) Password that will be used for the trove db user.
|
||||
# (Required) Password to connect to the database.
|
||||
#
|
||||
# [*dbname*]
|
||||
# (optionnal) Name of trove database.
|
||||
# Defaults to trove
|
||||
# (Optional) Name of the database.
|
||||
# Defaults to 'trove'.
|
||||
#
|
||||
# [*user*]
|
||||
# (optionnal) Name of trove user.
|
||||
# Defaults to trove
|
||||
# (Optional) User to connect to the database.
|
||||
# Defaults to 'trove'.
|
||||
#
|
||||
# [*encoding*]
|
||||
# (Optional) The charset to use for the database.
|
||||
# Default to undef.
|
||||
#
|
||||
# [*privileges*]
|
||||
# (Optional) Privileges given to the database user.
|
||||
# Default to 'ALL'
|
||||
#
|
||||
class trove::db::postgresql(
|
||||
$password,
|
||||
$dbname = 'trove',
|
||||
$user = 'trove'
|
||||
$dbname = 'trove',
|
||||
$user = 'trove',
|
||||
$encoding = undef,
|
||||
$privileges = 'ALL',
|
||||
) {
|
||||
|
||||
require postgresql::python
|
||||
|
||||
Class['trove::db::postgresql'] -> Service<| title == 'trove' |>
|
||||
Postgresql::Db[$dbname] ~> Exec<| title == 'trove-manage db_sync' |>
|
||||
Package['python-psycopg2'] -> Exec<| title == 'trove-manage db_sync' |>
|
||||
|
||||
|
||||
postgresql::db { $dbname:
|
||||
user => $user,
|
||||
password => $password,
|
||||
::openstacklib::db::postgresql { 'trove':
|
||||
password_hash => postgresql_password($user, $password),
|
||||
dbname => $dbname,
|
||||
user => $user,
|
||||
encoding => $encoding,
|
||||
privileges => $privileges,
|
||||
}
|
||||
|
||||
::Openstacklib::Db::Postgresql['trove'] ~> Exec<| title == 'trove-manage db_sync' |>
|
||||
|
||||
}
|
||||
|
@@ -3,24 +3,56 @@ require 'spec_helper'
|
||||
describe 'trove::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('trove').with(
|
||||
:user => 'trove',
|
||||
:password => 'pw'
|
||||
) }
|
||||
|
||||
context 'with only required parameters' do
|
||||
let :params do
|
||||
req_params
|
||||
end
|
||||
|
||||
it { is_expected.to contain_postgresql__server__db('trove').with(
|
||||
:user => 'trove',
|
||||
:password => 'md5e12ef276d200761a0808f17a5b076451'
|
||||
)}
|
||||
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 { is_expected.to contain_postgresql__server__db('trove').with(
|
||||
:user => 'trove',
|
||||
:password => 'md5e12ef276d200761a0808f17a5b076451'
|
||||
)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user