Skip to content

Commit

Permalink
Merge pull request puppetlabs#1225 from ekohl/use-major-version
Browse files Browse the repository at this point in the history
Clean up globals logic to support CentOS 8 stream
  • Loading branch information
sheenaajay authored Feb 1, 2021
2 parents 068e94a + 86981a6 commit e4f54cc
Show file tree
Hide file tree
Showing 34 changed files with 66 additions and 69 deletions.
31 changes: 14 additions & 17 deletions manifests/globals.pp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
# class.
$default_version = $facts['os']['family'] ? {
/^(RedHat|Linux)/ => $facts['os']['name'] ? {
'Fedora' => $facts['os']['release']['full'] ? {
'Fedora' => $facts['os']['release']['major'] ? {
/^(32|33)$/ => '12',
/^(31)$/ => '11.6',
/^(30)$/ => '11.2',
Expand All @@ -174,24 +174,24 @@
default => undef,
},
'Amazon' => '9.2',
default => $facts['os']['release']['full'] ? {
/^8\./ => '10',
/^7\./ => '9.2',
/^6\./ => '8.4',
/^5\./ => '8.1',
default => $facts['os']['release']['major'] ? {
'8' => '10',
'7' => '9.2',
'6' => '8.4',
'5' => '8.1',
default => undef,
},
},
'Debian' => $facts['os']['name'] ? {
'Debian' => $facts['os']['release']['full'] ? {
/^(squeeze|6\.)/ => '8.4',
/^(wheezy|7\.)/ => '9.1',
/^(jessie|8\.)/ => '9.4',
/^(stretch|9\.)/ => '9.6',
/^(buster|10\.)/ => '11',
'Debian' => $facts['os']['release']['major'] ? {
'6' => '8.4',
'7' => '9.1',
'8' => '9.4',
'9' => '9.6',
'10' => '11',
default => undef,
},
'Ubuntu' => $facts['os']['release']['full'] ? {
'Ubuntu' => $facts['os']['release']['major'] ? {
/^(10.04|10.10|11.04)$/ => '8.4',
/^(11.10|12.04|12.10|13.04|13.10)$/ => '9.1',
/^(14.04)$/ => '9.3',
Expand All @@ -204,10 +204,7 @@
},
default => undef,
},
'Archlinux' => $facts['os']['name'] ? {
/Archlinux/ => '9.2',
default => '9.2',
},
'Archlinux' => '9.2',
'Gentoo' => '9.5',
'FreeBSD' => '12',
'OpenBSD' => $facts['os']['release']['full'] ? {
Expand Down
14 changes: 7 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

# RHEL 5 uses SysV init, RHEL 6 uses upstart. RHEL 7 and 8 both use systemd.
'RedHat', 'CentOS', 'Scientific', 'OracleLinux': {
if $facts['os']['release']['full'] =~ /^[78].*/ {
if $facts['os']['release']['major'] in ['7', '8'] {
$service_reload = "systemctl reload ${service_name}"
$service_status = "systemctl status ${service_name}"
} else {
Expand All @@ -113,7 +113,7 @@

if $postgresql::globals::postgis_package_name {
$postgis_package_name = $postgresql::globals::postgis_package_name
} elsif $facts['os']['release']['full'] =~ /^5\./ {
} elsif $facts['os']['release']['major'] == '5' {
$postgis_package_name = 'postgis'
} elsif $postgis_version and versioncmp($postgis_version, '2') < 0 {
$postgis_package_name = "postgis${package_version}"
Expand Down Expand Up @@ -175,7 +175,7 @@

$client_package_name = pick($client_package_name, "postgresql-client-${version}")
$server_package_name = pick($server_package_name, "postgresql-${version}")
if $facts['os']['name'] == 'Debian' and $facts['os']['release']['full'] =~ /^10/ and $postgresql::globals::manage_package_repo != true {
if $facts['os']['name'] == 'Debian' and $facts['os']['release']['major'] == '10' and $postgresql::globals::manage_package_repo != true {
$contrib_package_name = pick($contrib_package_name, 'postgresql-contrib')
} else {
$contrib_package_name = pick($contrib_package_name, "postgresql-contrib-${version}")
Expand All @@ -189,8 +189,8 @@
}
$devel_package_name = pick($devel_package_name, 'libpq-dev')
$java_package_name = $facts['os']['name'] ? {
'Debian' => $facts['os']['release']['full'] ? {
/^6/ => pick($java_package_name, 'libpg-java'),
'Debian' => $facts['os']['release']['major'] ? {
'6' => pick($java_package_name, 'libpg-java'),
default => pick($java_package_name, 'libpostgresql-jdbc-java'),
},
default => pick($java_package_name, 'libpostgresql-jdbc-java'),
Expand All @@ -203,10 +203,10 @@
$bindir = pick($bindir, "/usr/lib/postgresql/${version}/bin")
$datadir = pick($datadir, "/var/lib/postgresql/${version}/main")
$confdir = pick($confdir, "/etc/postgresql/${version}/main")
if $facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['full'], '8.0') >= 0 {
if $facts['os']['name'] == 'Debian' and versioncmp($facts['os']['release']['major'], '8') >= 0 {
# Jessie uses systemd
$service_status = pick($service_status, "/usr/sbin/service ${service_name}@*-main status")
} elsif $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['full'], '15.04') >= 0 {
} elsif $facts['os']['name'] == 'Ubuntu' and versioncmp($facts['os']['release']['major'], '15.04') >= 0 {
# Ubuntu releases since vivid use systemd
$service_status = pick($service_status, "/usr/sbin/service ${service_name} status")
} else {
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@

# RedHat-based systems hardcode some PG* variables in the init script, and need to be overriden
# in /etc/sysconfig/pgsql/postgresql. Create a blank file so we can manage it with augeas later.
if ($facts['os']['family'] == 'RedHat') and ($facts['os']['release']['full'] !~ /^7|^8/) and ($facts['os']['name'] != 'Fedora') {
if ($facts['os']['family'] == 'RedHat') and ($facts['os']['release']['major'] !~ /^(7|8)$/) and ($facts['os']['name'] != 'Fedora') {
file { '/etc/sysconfig/pgsql/postgresql':
ensure => file,
replace => false,
Expand Down
4 changes: 2 additions & 2 deletions manifests/server/config_entry.pp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
# a systemd override for the port or update the sysconfig file, but this
# is managed for us in postgresql::server::config.
if $facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Ubuntu' {
if $name == 'port' and ( $facts['os']['release']['full'] =~ /^6/ or $facts['os']['release']['full'] =~ /^10\.04/ ) {
if $name == 'port' and $facts['os']['release']['major'] in ['6', '10.04'] {
exec { "postgresql_stop_${name}":
command => "service ${postgresql::server::service_name} stop",
onlyif => "service ${postgresql::server::service_name} status",
Expand All @@ -117,7 +117,7 @@
}
}
if $facts['os']['family'] == 'RedHat' {
if ! ($facts['os']['release']['full'] =~ /^7|^8/ or $facts['os']['name'] == 'Fedora') {
if ! ($facts['os']['release']['major'] in ['7', '8'] or $facts['os']['name'] == 'Fedora') {
if $name == 'port' {
# We need to force postgresql to stop before updating the port
# because puppet becomes confused and is unable to manage the
Expand Down
2 changes: 1 addition & 1 deletion manifests/server/initdb.pp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
# The package will take care of this for us the first time, but if we
# ever need to init a new db we need to copy these files explicitly
if $facts['os']['name'] == 'Debian' or $facts['os']['name'] == 'Ubuntu' {
if $facts['os']['release']['full'] =~ /^6/ or $facts['os']['release']['full'] =~ /^7/ or $facts['os']['release']['full'] =~ /^10\.04/ or $facts['os']['release']['full'] =~ /^12\.04/ {
if $facts['os']['release']['major'] in ['6', '7', '10.04', '12.04'] {
file { 'server.crt':
ensure => file,
path => "${datadir}/server.crt",
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/globals_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '7.1' },
release: { 'full' => '7.1', 'major' => '7' },
},
osfamily: 'RedHat',
}
Expand Down
6 changes: 3 additions & 3 deletions spec/unit/classes/lib/devel_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand Down Expand Up @@ -39,7 +39,7 @@
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.3' },
release: { 'full' => '6.3', 'major' => '6' },
},
}
end
Expand All @@ -53,7 +53,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.3' },
release: { 'full' => '6.3', 'major' => '6' },
},
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/classes/lib/java_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand All @@ -29,7 +29,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.4' },
release: { 'full' => '6.4', 'major' => '6' },
},
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/classes/lib/perl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.4' },
release: { 'full' => '6.4', 'major' => '6' },
},
}
end
Expand All @@ -28,7 +28,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/lib/pgdocs_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.4' },
release: { 'full' => '6.4', 'major' => '6' },
},
}
end
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/classes/lib/python_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.4' },
release: { 'full' => '6.4', 'major' => '6' },
},
}
end
Expand All @@ -28,7 +28,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/params_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
}
end
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/server/contrib_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
10 changes: 5 additions & 5 deletions spec/unit/classes/server/initdb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.0' },
release: { 'full' => '6.0', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down Expand Up @@ -53,7 +53,7 @@ class {'postgresql::server':
os: {
family: 'RedHat',
name: 'Amazon',
release: { 'full' => '1.0' },
release: { 'full' => '1.0', 'major' => '1' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down Expand Up @@ -85,7 +85,7 @@ class {'postgresql::server':
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.0' },
release: { 'full' => '6.0', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down Expand Up @@ -116,7 +116,7 @@ class { 'postgresql::server': }
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.0' },
release: { 'full' => '6.0', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down Expand Up @@ -146,7 +146,7 @@ class { 'postgresql::server': }
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.0' },
release: { 'full' => '6.0', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/server/plperl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/server/plpython_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'RedHat',
name: 'CentOS',
release: { 'full' => '6.8' },
release: { 'full' => '6.8', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/classes/server/postgis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
4 changes: 2 additions & 2 deletions spec/unit/defines/server/config_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '6.4' },
release: { 'full' => '6.4', 'major' => '6' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down Expand Up @@ -117,7 +117,7 @@
os: {
family: 'RedHat',
name: 'RedHat',
release: { 'full' => '7.0' },
release: { 'full' => '7.0', 'major' => '7' },
selinux: { 'enabled' => true },
},
kernel: 'Linux',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/defines/server/database_grant_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/defines/server/database_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/defines/server/db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
os: {
family: 'Debian',
name: 'Debian',
release: { 'full' => '8.0' },
release: { 'full' => '8.0', 'major' => '8' },
},
kernel: 'Linux',
id: 'root',
Expand Down
Loading

0 comments on commit e4f54cc

Please sign in to comment.