Fix postgresql manifest

Remove hardcoded postgresql version and paths because they broke
installation in CentOS7

Is compatible with CentOS6 master node

Implements: blueprint master-on-centos7

Change-Id: I660c4aa402188e1b089eab14f9478e3baa30310c
Co-Authored-By: Sergii Golovatiuk <sgolovatiuk@mirantis.com>
This commit is contained in:
Dmitry Teselkin 2015-11-18 21:02:29 +03:00 committed by Sergii Golovatiuk
parent 312de3725e
commit 07a56dc4f2
2 changed files with 117 additions and 24 deletions

View File

@ -1,14 +1,28 @@
$fuel_settings = parseyaml($astute_settings_yaml)
$postgres_default_version = '9.3'
if $::osfamily == 'RedHat' {
case $operatingsystemmajrelease {
'6': {
$postgres_default_version = '9.3'
$bindir = "/usr/pgsql-${postgres_default_version}/bin"
Class['postgresql::server'] -> Postgres_config<||>
Postgres_config { ensure => present }
postgres_config {
log_directory : value => "'/var/log/'";
log_filename : value => "'pgsql'";
log_rotation_age : value => "7d";
}
}
}
}
# install and configure postgresql server
class { 'postgresql::globals':
version => $postgres_default_version,
bindir => "/usr/pgsql-${postgres_default_version}/bin",
server_package_name => "postgresql-server",
client_package_name => "postgresql",
server_package_name => 'postgresql-server',
client_package_name => 'postgresql',
encoding => 'UTF8',
bindir => $bindir,
version => $postgres_default_version,
}
class { 'postgresql::server':
listen_addresses => '0.0.0.0',
@ -16,18 +30,18 @@ class { 'postgresql::server':
}
# nailgun db and grants
$database_name = $::fuel_settings['postgres']['nailgun_dbname']
$database_engine = "postgresql"
$database_port = "5432"
$database_user = $::fuel_settings['postgres']['nailgun_user']
$database_name = $::fuel_settings['postgres']['nailgun_dbname']
$database_engine = 'postgresql'
$database_port = '5432'
$database_user = $::fuel_settings['postgres']['nailgun_user']
$database_passwd = $::fuel_settings['postgres']['nailgun_password']
class {'docker::container': }
class { "nailgun::database":
user => $database_user,
password => $database_passwd,
dbname => $database_name,
class { 'nailgun::database':
user => $database_user,
password => $database_passwd,
dbname => $database_name,
}
# keystone db and grants
@ -39,7 +53,7 @@ postgresql::server::db { $keystone_dbname:
user => $keystone_dbuser,
password => $keystone_dbpass,
grant => 'all',
require => Class['::postgresql::server'],
require => Class['::postgresql::server'],
}
# ostf db and grants
@ -51,14 +65,5 @@ postgresql::server::db { $ostf_dbname:
user => $ostf_dbuser,
password => $ostf_dbpass,
grant => 'all',
require => Class['::postgresql::server'],
require => Class['::postgresql::server'],
}
Class['postgresql::server'] -> Postgres_config<||>
Postgres_config { ensure => present }
postgres_config {
log_directory : value => "'/var/log/'";
log_filename : value => "'pgsql'";
log_rotation_age : value => "7d";
}

View File

@ -3,5 +3,93 @@ require 'shared-examples'
manifest = 'master/postgres-only.pp'
describe manifest do
shared_examples 'catalog' do
context 'running on CentOS 6' do
let(:facts) do
Noop.centos_facts.merge({
:operatingsystemmajrelease => '6'
})
end
it 'should contain class postgresql::globals with proper bindir' do
should contain_class('postgresql::globals').with(
:bindir => '/usr/pgsql-9.3/bin'
)
end
it 'should contain postgres_configs with proper values' do
should contain_postgres_config('log_rotation_age').with(
:value => '7d'
)
should contain_postgres_config('log_filename').with(
:value => "'pgsql'"
)
should contain_postgres_config('log_directory').with(
:value => "'/var/log/'"
)
end
end
context 'running on CentOS 7' do
let(:facts) do
Noop.centos_facts.merge({
:operatingsystemmajrelease => '7'
})
end
it 'should contain class postgresql::globals with proper bindir' do
should contain_class('postgresql::globals').with(
:bindir => nil
)
end
end
it 'should configure postgres server' do
should contain_class('postgresql::server').with({
'listen_addresses' => '0.0.0.0',
'ip_mask_allow_all_users' => '0.0.0.0/0'
})
end
it 'should configure nailgun database' do
fuel_settings = Noop.puppet_function('parseyaml',
facts[:astute_settings_yaml])
database_name = fuel_settings['postgres']['nailgun_dbname']
database_user = fuel_settings['postgres']['nailgun_user']
database_passwd = fuel_settings['postgres']['nailgun_password']
should contain_class('nailgun::database').with({
'user' => database_user,
'password' => database_passwd,
'dbname' => database_name
})
end
it 'should configure keystone database' do
fuel_settings = Noop.puppet_function('parseyaml',
facts[:astute_settings_yaml])
keystone_dbname = fuel_settings['postgres']['keystone_dbname']
keystone_dbuser = fuel_settings['postgres']['keystone_user']
keystone_dbpass = fuel_settings['postgres']['keystone_password']
should contain_postgresql__server__db("#{keystone_dbname}").with({
'user' => keystone_dbuser,
'password' => keystone_dbpass,
'grant' => 'all'
})
end
it 'should configure ostf database' do
fuel_settings = Noop.puppet_function('parseyaml',
facts[:astute_settings_yaml])
ostf_dbname = fuel_settings['postgres']['ostf_dbname']
ostf_dbuser = fuel_settings['postgres']['ostf_user']
ostf_dbpass = fuel_settings['postgres']['ostf_password']
should contain_postgresql__server__db("#{ostf_dbname}").with({
'user' => ostf_dbuser,
'password' => ostf_dbpass,
'grant' => 'all'
})
end
end
test_centos manifest
end