Add support to custom xlogdir parameter

Having a custom xlogdir location is desiderable for performances in many production environments
This commit is contained in:
Marco Nenciarini 2013-09-25 19:00:24 +02:00
parent 68e0a6cc03
commit 2b81d5cb63
4 changed files with 35 additions and 2 deletions

View file

@ -27,6 +27,7 @@ class postgresql::globals (
$datadir = undef,
$confdir = undef,
$bindir = undef,
$xlogdir = undef,
$user = undef,
$group = undef,

View file

@ -29,6 +29,7 @@ class postgresql::server (
$postgresql_conf_path = $postgresql::params::postgresql_conf_path,
$datadir = $postgresql::params::datadir,
$xlogdir = $postgresql::params::xlogdir,
$pg_hba_conf_defaults = $postgresql::params::pg_hba_conf_defaults,

View file

@ -4,6 +4,7 @@ class postgresql::server::initdb {
$needs_initdb = $postgresql::server::needs_initdb
$initdb_path = $postgresql::server::initdb_path
$datadir = $postgresql::server::datadir
$xlogdir = $postgresql::server::xlogdir
$encoding = $postgresql::server::encoding
$locale = $postgresql::server::locale
$group = $postgresql::server::group
@ -18,6 +19,16 @@ class postgresql::server::initdb {
mode => '0700',
}
if($xlogdir) {
# Make sure the xlog directory exists, and has the correct permissions.
file { $xlogdir:
ensure => directory,
owner => $user,
group => $group,
mode => '0700',
}
}
if($needs_initdb) {
# Build up the initdb command.
#
@ -25,9 +36,13 @@ class postgresql::server::initdb {
# initdb command don't accept this switch. So if the user didn't pass the
# parameter, lets not pass the switch at all.
$ic_base = "${initdb_path} --encoding '${encoding}' --pgdata '${datadir}'"
$initdb_command = $locale ? {
$ic_xlog = $xlogdir ? {
undef => $ic_base,
default => "${ic_base} --locale '${locale}'"
default => "${ic_base} --xlogdir '${xlogdir}'"
}
$initdb_command = $locale ? {
undef => $ic_xlog,
default => "${ic_xlog} --locale '${locale}'"
}
# This runs the initdb command, we use the existance of the PG_VERSION
@ -48,5 +63,14 @@ class postgresql::server::initdb {
recurse => true,
force => true,
}
if($xlogdir) {
# Make sure the xlog directory exists, and has the correct permissions.
file { $xlogdir:
ensure => absent,
recurse => true,
force => true,
}
}
}
}

View file

@ -37,6 +37,7 @@ describe 'postgresql::server', :type => :class do
{
:ensure => 'absent',
:datadir => '/my/path',
:xlogdir => '/xlog/path',
}
end
@ -57,6 +58,12 @@ describe 'postgresql::server', :type => :class do
:ensure => 'absent',
})
end
it 'should remove xlogdir' do
should contain_file('/xlog/path').with({
:ensure => 'absent',
})
end
end
describe 'package_ensure => absent' do