Skip to content

Commit

Permalink
Drop postgresql 8.1/RHEL5 specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
bastelfreak committed Aug 31, 2023
1 parent f094048 commit 98321c4
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 63 deletions.
2 changes: 0 additions & 2 deletions manifests/globals.pp
Expand Up @@ -196,7 +196,6 @@
'8' => '10',
'7' => '9.2',
'6' => '8.4',
'5' => '8.1',
default => undef,
},
},
Expand Down Expand Up @@ -248,7 +247,6 @@
}

$default_postgis_version = $globals_version ? {
'8.1' => '1.3.6',
'8.4' => '2.0',
'9.0' => '2.1',
'9.1' => '2.1',
Expand Down
20 changes: 5 additions & 15 deletions manifests/server/database.pp
Expand Up @@ -52,16 +52,11 @@

# Optionally set the locale switch. Older versions of createdb may not accept
# --locale, so if the parameter is undefined its safer not to pass it.
if ($version != '8.1') {
$locale_option = $locale ? {
undef => '',
default => "LC_COLLATE = '${locale}' LC_CTYPE = '${locale}'",
}
$public_revoke_privilege = 'CONNECT'
} else {
$locale_option = ''
$public_revoke_privilege = 'ALL'
$locale_option = $locale ? {
undef => '',
default => "LC_COLLATE = '${locale}' LC_CTYPE = '${locale}'",
}
$public_revoke_privilege = 'CONNECT'

$template_option = $template ? {
undef => '',
Expand Down Expand Up @@ -96,14 +91,9 @@
}

if $comment {
# The shobj_description function was only introduced with 8.2
$comment_information_function = $version ? {
'8.1' => 'obj_description',
default => 'shobj_description',
}
Postgresql_psql["CREATE DATABASE \"${dbname}\""]
-> postgresql_psql { "COMMENT ON DATABASE \"${dbname}\" IS '${comment}'":
unless => "SELECT 1 FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.${comment_information_function}(d.oid, 'pg_database') = '${comment}'", # lint:ignore:140chars
unless => "SELECT 1 FROM pg_catalog.pg_database d WHERE datname = '${dbname}' AND pg_catalog.shobj_description(d.oid, 'pg_database') = '${comment}'", # lint:ignore:140chars
db => $dbname,
}
}
Expand Down
9 changes: 0 additions & 9 deletions manifests/server/instance/config.pp
Expand Up @@ -89,24 +89,16 @@
user => 'all',
}

# Lets setup the base rules
$local_auth_option = $version ? {
'8.1' => 'sameuser',
default => undef,
}

postgresql::server::pg_hba_rule {
"local access as postgres user for instance ${name}":
type => 'local',
user => $user,
auth_method => 'ident',
auth_option => $local_auth_option,
order => 1;

"local access to database with same name for instance ${name}":
type => 'local',
auth_method => 'ident',
auth_option => $local_auth_option,
order => 2;

"allow localhost TCP access to postgresql user for instance ${name}":
Expand Down Expand Up @@ -174,7 +166,6 @@
}
else {
$package_name = $facts['os']['release']['major'] ? {
'5' => 'policycoreutils',
'6' => 'policycoreutils-python',
'7' => 'policycoreutils-python',
default => 'policycoreutils-python-utils',
Expand Down
1 change: 0 additions & 1 deletion manifests/server/pg_hba_rule.pp
Expand Up @@ -72,7 +72,6 @@
'8.4' => ['trust', 'reject', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'ldap', 'cert', 'pam'],
'8.3' => ['trust', 'reject', 'md5', 'crypt', 'password', 'gss', 'sspi', 'krb5', 'ident', 'ldap', 'pam'],
'8.2' => ['trust', 'reject', 'md5', 'crypt', 'password', 'krb5', 'ident', 'ldap', 'pam'],
'8.1' => ['trust', 'reject', 'md5', 'crypt', 'password', 'krb5', 'ident', 'pam'],
default => ['trust', 'reject', 'scram-sha-256', 'md5', 'password', 'gss', 'sspi', 'krb5', 'ident', 'peer', 'ldap', 'radius', 'cert', 'pam', 'crypt', 'bsd'] # lint:ignore:140chars
}

Expand Down
8 changes: 2 additions & 6 deletions spec/acceptance/db_spec.rb
Expand Up @@ -37,12 +37,8 @@ class { 'postgresql::server':

result = psql('--command="SELECT 1 FROM pg_roles WHERE rolname=\'test-user\'"')
expect(result.stdout).to match(%r{\(1 row\)})
comment_information_function = if Gem::Version.new(postgresql_version) > Gem::Version.new('8.1')
'shobj_description'
else
'obj_description'
end
result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.#{comment_information_function}(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.#{comment_information_function}(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength

result = psql("--dbname postgresql-test-db --command=\"SELECT pg_catalog.shobj_description(d.oid, 'pg_database') FROM pg_catalog.pg_database d WHERE datname = 'postgresql-test-db' AND pg_catalog.shobj_description(d.oid, 'pg_database') = 'testcomment'\"") # rubocop:disable Layout/LineLength
expect(result.stdout).to match(%r{\(1 row\)})
ensure
psql('--command=\'drop database "postgresql-test-db"\'')
Expand Down
19 changes: 0 additions & 19 deletions spec/acceptance/server/grant_role_spec.rb
Expand Up @@ -7,16 +7,12 @@
let(:user) { 'psql_grant_role_tester' }
let(:group) { 'test_group' }
let(:password) { 'psql_grant_role_pw' }
let(:version) do
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
end
let(:pp_one) do
<<-MANIFEST.unindent
$db = #{db}
$user = #{user}
$group = #{group}
$password = #{password}
$version = '#{version}'
class { 'postgresql::server': }
Expand All @@ -34,19 +30,12 @@ class { 'postgresql::server': }
require => Postgresql::Server::Role[$user],
}
# Lets setup the base rules
$local_auth_option = $version ? {
'8.1' => 'sameuser',
default => undef,
}
# Create a rule for the user
postgresql::server::pg_hba_rule { "allow ${user}":
type => 'local',
database => $db,
user => $user,
auth_method => 'ident',
auth_option => $local_auth_option,
order => 1,
}
Expand All @@ -70,7 +59,6 @@ class { 'postgresql::server': }
$user = "#{user}"
$group = "#{group}"
$password = #{password}
$version = '#{version}'
class { 'postgresql::server': }
Expand All @@ -88,19 +76,12 @@ class { 'postgresql::server': }
require => Postgresql::Server::Role[$user],
}
# Lets setup the base rules
$local_auth_option = $version ? {
'8.1' => 'sameuser',
default => undef,
}
# Create a rule for the user
postgresql::server::pg_hba_rule { "allow ${user}":
type => 'local',
database => $db,
user => $user,
auth_method => 'ident',
auth_option => $local_auth_option,
order => 1,
}
Expand Down
11 changes: 0 additions & 11 deletions spec/acceptance/server/schema_spec.rb
Expand Up @@ -3,15 +3,11 @@
require 'spec_helper_acceptance'

describe 'postgresql::server::schema:' do
let(:version) do
'8.1' if os[:family] == 'redhat' && os[:release].start_with?('5')
end
let(:pp) do
<<-MANIFEST.unindent
$db = 'schema_test'
$user = 'psql_schema_tester'
$password = 'psql_schema_pw'
$version = '#{version}'
class { 'postgresql::server': }
Expand All @@ -29,19 +25,12 @@ class { 'postgresql::server': }
require => Postgresql::Server::Role[$user],
}
# Lets setup the base rules
$local_auth_option = $version ? {
'8.1' => 'sameuser',
default => undef,
}
# Create a rule for the user
postgresql::server::pg_hba_rule { "allow ${user}":
type => 'local',
database => $db,
user => $user,
auth_method => 'ident',
auth_option => $local_auth_option,
order => 1,
}
Expand Down

0 comments on commit 98321c4

Please sign in to comment.