Merge pull request #473 from mhjacks/pgdata_patch

Support changing PGDATA on RedHat
This commit is contained in:
Ashley Penney 2014-08-28 13:10:10 -04:00
commit cab1645df5
2 changed files with 36 additions and 0 deletions

View file

@ -73,6 +73,18 @@ define postgresql::server::config_entry (
before => Class['postgresql::server::reload'], 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'],
}
}
} }
} }

View file

@ -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