diff --git a/manifests/globals.pp b/manifests/globals.pp index 5bd1b09..ade1f57 100644 --- a/manifests/globals.pp +++ b/manifests/globals.pp @@ -27,6 +27,7 @@ class postgresql::globals ( $datadir = undef, $confdir = undef, $bindir = undef, + $xlogdir = undef, $user = undef, $group = undef, diff --git a/manifests/server.pp b/manifests/server.pp index eb71b3d..ab40906 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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, diff --git a/manifests/server/initdb.pp b/manifests/server/initdb.pp index ba32cd3..a56f19c 100644 --- a/manifests/server/initdb.pp +++ b/manifests/server/initdb.pp @@ -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, + } + } } } diff --git a/spec/unit/classes/server_spec.rb b/spec/unit/classes/server_spec.rb index 74a6227..3af85af 100644 --- a/spec/unit/classes/server_spec.rb +++ b/spec/unit/classes/server_spec.rb @@ -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