From 4d70c188e83b7cce7517228b7e8661719ebc0bb0 Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 21 Feb 2013 19:12:42 +0000 Subject: [PATCH 1/2] (GH-130) Fix 'include' parameter for Postgresql 8.1 This removes the 'include' parameter for PostgreSQL 8.1 as it was failing on Centos 5. Also added Centos 5 system tests using our new Vagrant boxes. Signed-off-by: Ken Barber --- manifests/config/beforeservice.pp | 28 +++++++++++-------- .../system_default_postgres.rb | 2 ++ spec/system/distros/centos5_64/Vagrantfile | 12 ++++++++ .../distros/centos5_64/non_default_pg_spec.rb | 7 +++++ .../centos5_64/system_default_pg_spec.rb | 8 ++++++ 5 files changed, 46 insertions(+), 11 deletions(-) create mode 100644 spec/system/distros/centos5_64/Vagrantfile create mode 100644 spec/system/distros/centos5_64/non_default_pg_spec.rb create mode 100644 spec/system/distros/centos5_64/system_default_pg_spec.rb diff --git a/manifests/config/beforeservice.pp b/manifests/config/beforeservice.pp index 6c87a72..8d0886d 100644 --- a/manifests/config/beforeservice.pp +++ b/manifests/config/beforeservice.pp @@ -120,19 +120,25 @@ class postgresql::config::beforeservice( } # Here we are adding an 'include' line so that users have the option of - # managing their own settings in a second conf file. - file_line { 'postgresql.conf#include': - path => $postgresql_conf_path, - line => "include 'postgresql_puppet_extras.conf'", - notify => Service['postgresqld'], + # managing their own settings in a second conf file. This only works for + # postgresql 8.2 and higher. + if(versioncmp($postgresql::params::version, '8.2') >= 0) { + # Since we're adding an "include" for this extras config file, we need + # to make sure it exists. + exec { "create_postgresql_conf_path": + command => "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf", + path => '/usr/bin:/bin', + unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]" + } + + file_line { 'postgresql.conf#include': + path => $postgresql_conf_path, + line => "include 'postgresql_puppet_extras.conf'", + require => Exec["create_postgresql_conf_path"], + notify => Service['postgresqld'], + } } - # Since we're adding an "include" for this extras config file, we need - # to make sure it exists. - exec { "touch `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf" : - path => '/usr/bin:/bin', - unless => "[ -f `dirname ${postgresql_conf_path}`/postgresql_puppet_extras.conf ]" - } # TODO: is this a reasonable place for this firewall stuff? # TODO: figure out a way to make this not platform-specific; debian and ubuntu have diff --git a/spec/support/shared_examples/system_default_postgres.rb b/spec/support/shared_examples/system_default_postgres.rb index 8a8ead5..a5845d4 100644 --- a/spec/support/shared_examples/system_default_postgres.rb +++ b/spec/support/shared_examples/system_default_postgres.rb @@ -213,6 +213,8 @@ shared_examples :system_default_postgres do describe 'postgresql.conf include' do it "should support an 'include' directive at the end of postgresql.conf" do + pending('no support for include directive with centos 5', :if => vm == :centos5) + test_class = 'class {"postgresql_tests::system_default::test_pgconf_include": }' # Run once to check for crashes diff --git a/spec/system/distros/centos5_64/Vagrantfile b/spec/system/distros/centos5_64/Vagrantfile new file mode 100644 index 0000000..a5a89b2 --- /dev/null +++ b/spec/system/distros/centos5_64/Vagrantfile @@ -0,0 +1,12 @@ +require File.expand_path(File.join(__FILE__, '../../../../support/vagrant_common')) + +Vagrant::Config.run do |config| + + config.vm.define :centos5 do |vm_config| + vm_config.vm.box = "centos-58-x64" + vm_config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/centos-58-x64.box" + end + + apply_common_vagrant_config(config) + +end diff --git a/spec/system/distros/centos5_64/non_default_pg_spec.rb b/spec/system/distros/centos5_64/non_default_pg_spec.rb new file mode 100644 index 0000000..8845f2f --- /dev/null +++ b/spec/system/distros/centos5_64/non_default_pg_spec.rb @@ -0,0 +1,7 @@ +require 'support/shared_examples/non_default_postgres' + +describe "CentOS 5, 64-bit: non-default postgres" do + let(:vagrant_dir) { File.dirname(__FILE__) } + let(:vm) { :centos5 } + it_behaves_like :non_default_postgres +end diff --git a/spec/system/distros/centos5_64/system_default_pg_spec.rb b/spec/system/distros/centos5_64/system_default_pg_spec.rb new file mode 100644 index 0000000..b74f592 --- /dev/null +++ b/spec/system/distros/centos5_64/system_default_pg_spec.rb @@ -0,0 +1,8 @@ +require 'support/shared_examples/system_default_postgres' + +describe "CentOS 5, 64-bit: default system postgres" do + let(:vagrant_dir) { File.dirname(__FILE__) } + let(:vm) { :centos5 } + let(:service_name) { 'postgresql' } + it_behaves_like :system_default_postgres +end From 0a76406e23924062e8e14f106e15abd1bb6445ec Mon Sep 17 00:00:00 2001 From: Ken Barber Date: Thu, 21 Feb 2013 21:23:56 +0000 Subject: [PATCH 2/2] (GH-130) Amend system tests for Centos 5 Skip tests that don't apply to Centos 5, and make sure the parent directory for tablespace correction has the correct SELinux settings for tablespace management. Signed-off-by: Ken Barber --- .../shared_examples/non_default_postgres.rb | 1 + .../system_default_postgres.rb | 1 + .../system_default/test_tablespace.pp | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/spec/support/shared_examples/non_default_postgres.rb b/spec/support/shared_examples/non_default_postgres.rb index ef931fc..f7d070f 100644 --- a/spec/support/shared_examples/non_default_postgres.rb +++ b/spec/support/shared_examples/non_default_postgres.rb @@ -41,6 +41,7 @@ shared_examples :non_default_postgres do it 'with locale and charset, the postgres database should reflect that locale' do pending('no support for initdb with lucid', :if => vm == :lucid) + pending('no support for locale parameter with centos 5', :if => vm == :centos5) manifest = <<-EOS # Set global locale and charset option, and try installing postgres diff --git a/spec/support/shared_examples/system_default_postgres.rb b/spec/support/shared_examples/system_default_postgres.rb index a5845d4..7320269 100644 --- a/spec/support/shared_examples/system_default_postgres.rb +++ b/spec/support/shared_examples/system_default_postgres.rb @@ -51,6 +51,7 @@ shared_examples :system_default_postgres do end it 'should take a locale parameter' do + pending('no support for locale parameter with centos 5', :if => vm == :centos5) manifest = <<-EOS include postgresql::server postgresql::db { 'test1': diff --git a/spec/system/test_module/manifests/system_default/test_tablespace.pp b/spec/system/test_module/manifests/system_default/test_tablespace.pp index 5d67f8c..86e47ed 100644 --- a/spec/system/test_module/manifests/system_default/test_tablespace.pp +++ b/spec/system/test_module/manifests/system_default/test_tablespace.pp @@ -20,15 +20,18 @@ class postgresql_tests::system_default::test_tablespace { include postgresql::server - file { '/tmp': - ensure => 'directory', - } file { '/tmp/pg_tablespaces': - ensure => 'directory', - owner => 'postgres', - group => 'postgres', - mode => '0700', - require => File['/tmp'], + ensure => 'directory', + owner => 'postgres', + group => 'postgres', + mode => '0700', + }~> + # This works around rubies that lack Selinux support, I'm looking at you RHEL5 + exec { "chcon system_u:object_r:postgresql_db_t /tmp/pg_tablespaces": + refreshonly => true, + path => "/bin:/usr/bin", + onlyif => "which chcon", + before => File["/tmp/pg_tablespaces/space1", "/tmp/pg_tablespaces/space2"] } postgresql::tablespace{ 'tablespace1':