From a00eab6937d9fe1bd03f41bebd410d60e7989366 Mon Sep 17 00:00:00 2001 From: Martin Jackson Date: Wed, 20 Aug 2014 20:16:45 -0500 Subject: [PATCH 1/3] Support changing PGDATA on RedHat --- manifests/server/config_entry.pp | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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'], + } + } } } From 7828cf3f73efa566d2c3e64a658f2593232a6038 Mon Sep 17 00:00:00 2001 From: Martin Jackson Date: Thu, 21 Aug 2014 21:58:11 -0500 Subject: [PATCH 2/3] Create acceptance test for pgdata --- spec/acceptance/alternative_pgdata_spec.rb | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 spec/acceptance/alternative_pgdata_spec.rb diff --git a/spec/acceptance/alternative_pgdata_spec.rb b/spec/acceptance/alternative_pgdata_spec.rb new file mode 100644 index 0000000..6fee9b2 --- /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('-D /var/pgsql --command="\l" postgres', 'postgres') do |r| + expect(r.stdout).to match(/List of databases/) + end + end + +end + + + From 8997ea16c5921099d069920fac1f0fb2a74816dc Mon Sep 17 00:00:00 2001 From: Martin Jackson Date: Sun, 24 Aug 2014 08:19:28 -0500 Subject: [PATCH 3/3] Remove bogus -D argument --- spec/acceptance/alternative_pgdata_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/acceptance/alternative_pgdata_spec.rb b/spec/acceptance/alternative_pgdata_spec.rb index 6fee9b2..1e7c3d9 100644 --- a/spec/acceptance/alternative_pgdata_spec.rb +++ b/spec/acceptance/alternative_pgdata_spec.rb @@ -13,7 +13,7 @@ describe 'postgres::server', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osf end it 'can connect with psql' do - psql('-D /var/pgsql --command="\l" postgres', 'postgres') do |r| + psql('--command="\l" postgres', 'postgres') do |r| expect(r.stdout).to match(/List of databases/) end end