6ba3179916
The change introduced in b781849882
added
a complex operation that was not handled correctly for all operating
systems. This fix includes the following corrections:
- Change the systemd config and reload systemd for datadir changes in
RHEL 7, and move configuration for this into
postgresql::server::config since it is managing both the PGDATA and
PGPORT variables
- Make sure Debian systems stop the service before changing the datadir
- Recreate cert links after running initdb in Debian and early ubuntu
- Change the port in the port spec to avoid selinux issues
- Turn off selinux in pgdata spec to avoid selinux issues
- Correct syntax for describing presence of a directory in pgdata spec
- Move the pgdata spec to the end of the tests so that puppet doesn't
have to manager purging and recreating the original datadir
- Update README to describe all caveats of using this parameter
34 lines
1 KiB
Ruby
34 lines
1 KiB
Ruby
require 'spec_helper_acceptance'
|
|
|
|
# These tests ensure that postgres can change itself to an alternative pgdata
|
|
# location properly.
|
|
|
|
# Allow postgresql to use /tmp/* as a datadir
|
|
if fact('osfamily') == 'RedHat'
|
|
shell("setenforce 0")
|
|
end
|
|
|
|
describe 'postgres::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
|
it 'on an alternative pgdata location' do
|
|
pp = <<-EOS
|
|
#file { '/var/lib/pgsql': ensure => directory, } ->
|
|
# needs_initdb will be true by default for all OS's except Debian
|
|
# in order to change the datadir we need to tell it explicitly to call initdb
|
|
class { 'postgresql::server': datadir => '/tmp/data', needs_initdb => true }
|
|
EOS
|
|
|
|
apply_manifest(pp, :catch_failures => true)
|
|
apply_manifest(pp, :catch_changes => true)
|
|
end
|
|
|
|
describe file('/tmp/data') do
|
|
it { should be_directory }
|
|
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
|