diff --git a/manifests/server/config_entry.pp b/manifests/server/config_entry.pp index 9054888..a3c029c 100644 --- a/manifests/server/config_entry.pp +++ b/manifests/server/config_entry.pp @@ -73,6 +73,18 @@ define postgresql::server::config_entry ( before => Class['postgresql::server::reload'], } } + + if $name == 'data_directory' { + augeas { 'override PGDATA in /etc/sysconfig/pgsql/postgresql': + lens => 'Shellvars.lns', + incl => '/etc/sysconfig/pgsql/*', + context => '/files/etc/sysconfig/pgsql/postgresql', + changes => "set PGDATA ${value}", + require => File['/etc/sysconfig/pgsql/postgresql'], + notify => Class['postgresql::server::service'], + before => Class['postgresql::server::reload'], + } + } } } diff --git a/spec/acceptance/alternative_pgdata_spec.rb b/spec/acceptance/alternative_pgdata_spec.rb new file mode 100644 index 0000000..1e7c3d9 --- /dev/null +++ b/spec/acceptance/alternative_pgdata_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper_acceptance' + +# These tests ensure that postgres can change itself to an alternative pgdata +# location properly. +describe 'postgres::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do + it 'on an alternative pgdata location' do + pp = <<-EOS + class { 'postgresql::server': data_directory => '/var/pgsql' } + EOS + + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + it 'can connect with psql' do + psql('--command="\l" postgres', 'postgres') do |r| + expect(r.stdout).to match(/List of databases/) + end + end + +end + + +