Skip to content

Commit a6ccfb2

Browse files
committed
(MODULES-2968) Add default postgis version for 9.5
This commit also updates the logic that determines the postgis version so that if version association is missing in the future, it will still compile.
1 parent 3e8ca93 commit a6ccfb2

File tree

3 files changed

+28
-11
lines changed

3 files changed

+28
-11
lines changed

manifests/globals.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,9 @@
132132
'91' => '1.5',
133133
'9.2' => '2.0',
134134
'9.3' => '2.1',
135-
'9.4' => '2.1',
136135
'93' => '2.1',
136+
'9.4' => '2.1',
137+
'9.5' => '2.2',
137138
default => undef,
138139
}
139140
$globals_postgis_version = $postgis_version ? {

manifests/params.pp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@
7676
$perl_package_name = pick($perl_package_name, 'perl-DBD-Pg')
7777
$python_package_name = pick($python_package_name, 'python-psycopg2')
7878

79-
$postgis_package_name = pick(
80-
$postgis_package_name,
81-
$::operatingsystemrelease ? {
82-
/^5\./ => 'postgis',
83-
default => versioncmp($postgis_version, '2') ? {
84-
'-1' => "postgis${package_version}",
85-
default => "postgis2_${package_version}",}
86-
}
87-
)
79+
if $postgresql::globals::postgis_package_name {
80+
$postgis_package_name = $postgresql::globals::postgis_package_name
81+
} elsif $::operatingsystemrelease =~ /^5\./ {
82+
$postgis_package_name = 'postgis'
83+
} elsif $postgis_version and versioncmp($postgis_version, '2') < 0 {
84+
$postgis_package_name = "postgis${package_version}"
85+
} else {
86+
$postgis_package_name = "postgis2_${package_version}"
87+
}
8888
}
8989

9090
'Archlinux': {
@@ -141,7 +141,7 @@
141141
$client_package_name = pick($client_package_name, "postgresql-client-${version}")
142142
$server_package_name = pick($server_package_name, "postgresql-${version}")
143143
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
144-
if versioncmp($postgis_version, '2') < 0 {
144+
if $postgis_version and versioncmp($postgis_version, '2') < 0 {
145145
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis")
146146
} else {
147147
$postgis_package_name = pick($postgis_package_name, "postgresql-${version}-postgis-${postgis_version}")

spec/unit/classes/server_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{
66
:osfamily => 'Debian',
77
:operatingsystem => 'Debian',
8+
:lsbdistid => 'Debian',
89
:operatingsystemrelease => '6.0',
910
:concat_basedir => tmpfilename('server'),
1011
:kernel => 'Linux',
@@ -139,4 +140,19 @@
139140
is_expected.to contain_exec('postgresql_initdb')
140141
end
141142
end
143+
144+
describe 'postgresql_version' do
145+
let(:pre_condition) do
146+
<<-EOS
147+
class { 'postgresql::globals':
148+
manage_package_repo => true,
149+
version => '99.5',
150+
before => Class['postgresql::server'],
151+
}
152+
EOS
153+
end
154+
it 'contains the correct package version' do
155+
is_expected.to contain_class('postgresql::repo').with_version('99.5')
156+
end
157+
end
142158
end

0 commit comments

Comments
 (0)