Skip to content

Commit 78bbe0d

Browse files
author
Ashley Penney
committed
Merge pull request puppetlabs#415 from apenney/rhel7
[WIP] Fixes to tests and RHEL7 support.
2 parents 702998d + bb26d47 commit 78bbe0d

16 files changed

+180
-40
lines changed

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ This setting can be used to override the default postgresql PL/perl package name
288288
####`python_package_name`
289289
This setting can be used to override the default postgresql Python package name. If not specified, the module will use whatever package name is the default for your OS distro.
290290

291+
####`service_ensure`
292+
This setting can be used to override the default postgresql service ensure status. If not specified, the module will use `ensure` instead.
293+
291294
####`service_name`
292295
This setting can be used to override the default postgresql service name. If not specified, the module will use whatever service name is the default for your OS distro.
293296

@@ -837,11 +840,17 @@ Works with versions of PostgreSQL from 8.1 through 9.2.
837840
Current it is only actively tested with the following operating systems:
838841

839842
* Debian 6.x and 7.x
840-
* Centos 5.x and 6.x
841-
* Ubuntu 10.04 and 12.04
843+
* Centos 5.x, 6.x, and 7.x.
844+
* Ubuntu 10.04 and 12.04, 14.04
842845

843846
Although patches are welcome for making it work with other OS distros, it is considered best effort.
844847

848+
### RHEL7
849+
850+
Currently the following features are unsupported:
851+
852+
* Postgis (There is no existing postgis package for RHEL7, and it's not in EPEL7 yet.)
853+
845854
Development
846855
------------
847856

manifests/globals.pp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
},
6060
'Amazon' => '9.2',
6161
default => $::operatingsystemrelease ? {
62+
/^7\./ => '9.2',
6263
/^6\./ => '8.4',
6364
/^5\./ => '8.1',
6465
default => undef,
@@ -91,6 +92,7 @@
9192
}
9293

9394
$default_postgis_version = $globals_version ? {
95+
'8.1' => '1.3.6',
9496
'8.4' => '1.5',
9597
'9.0' => '1.5',
9698
'9.1' => '1.5',
@@ -101,9 +103,12 @@
101103

102104
# Setup of the repo only makes sense globally, so we are doing this here.
103105
if($manage_package_repo) {
104-
class { 'postgresql::repo':
105-
ensure => $ensure,
106-
version => $globals_version
106+
# Workaround the lack of RHEL7 repositories for now.
107+
if ! ($::operatingsystem == 'RedHat' and $::operatingsystemrelease =~ /^7/) {
108+
class { 'postgresql::repo':
109+
ensure => $ensure,
110+
version => $globals_version
111+
}
107112
}
108113
}
109114
}

manifests/params.pp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PRIVATE CLASS: do not use directly
22
class postgresql::params inherits postgresql::globals {
3-
$ensure = true
3+
$ensure = present
44
$version = $globals_version
55
$postgis_version = $globals_postgis_version
66
$listen_addresses = 'localhost'
@@ -11,6 +11,7 @@
1111
$ipv6acls = []
1212
$encoding = $encoding
1313
$locale = $locale
14+
$service_ensure = undef
1415
$service_provider = $service_provider
1516
$manage_firewall = $manage_firewall
1617
$manage_pg_hba_conf = pick($manage_pg_hba_conf, true)
@@ -62,9 +63,11 @@
6263

6364
$postgis_package_name = pick(
6465
$postgis_package_name,
65-
versioncmp($postgis_version, '2') ? {
66-
'-1' => "postgis${package_version}",
67-
default => "postgis2_${package_version}",
66+
$::operatingsystemrelease ? {
67+
/5/ => 'postgis',
68+
default => versioncmp($postgis_version, '2') ? {
69+
'-1' => "postgis${package_version}",
70+
default => "postgis2_${package_version}",}
6871
}
6972
)
7073
}

manifests/server.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
$plperl_package_name = $postgresql::params::plperl_package_name,
1212

13+
$service_ensure = $postgresql::params::service_ensure,
1314
$service_name = $postgresql::params::service_name,
1415
$service_provider = $postgresql::params::service_provider,
1516
$service_status = $postgresql::params::service_status,

manifests/server/config.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104

105105
# RedHat-based systems hardcode some PG* variables in the init script, and need to be overriden
106106
# in /etc/sysconfig/pgsql/postgresql. Create a blank file so we can manage it with augeas later.
107-
if ($::osfamily == 'RedHat') {
107+
if ($::osfamily == 'RedHat') and ($::operatingsystemrelease !~ /^7/) {
108108
file { '/etc/sysconfig/pgsql/postgresql':
109109
ensure => present,
110110
replace => false,

manifests/server/config_entry.pp

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,48 @@
2626
}
2727
}
2828

29-
if ($::osfamily == 'RedHat') {
30-
if ($name == 'port') {
31-
augeas { 'override PGPORT in /etc/sysconfig/pgsql/postgresql':
32-
lens => 'Shellvars.lns',
33-
incl => '/etc/sysconfig/pgsql/*',
34-
context => '/files/etc/sysconfig/pgsql/postgresql',
35-
changes => "set PGPORT $value",
36-
require => File['/etc/sysconfig/pgsql/postgresql'],
37-
notify => Class['postgresql::server::service'],
38-
before => Class['postgresql::server::reload'],
29+
# We have to handle ports in a weird and special way. On Redhat we either
30+
# have to create a systemd override for the port or update the sysconfig
31+
# file.
32+
if $::osfamily == 'RedHat' {
33+
if $::operatingsystemrelease =~ /^7/ {
34+
if $name == 'port' {
35+
file { 'systemd-port-override':
36+
ensure => present,
37+
path => '/etc/systemd/system/postgresql.service',
38+
owner => root,
39+
group => root,
40+
content => template('postgresql/systemd-port-override.erb'),
41+
notify => [ Exec['restart-systemd'], Class['postgresql::server::service'] ],
42+
before => Class['postgresql::server::reload'],
43+
}
44+
exec { 'restart-systemd':
45+
command => 'systemctl daemon-reload',
46+
refreshonly => true,
47+
path => '/bin:/usr/bin:/usr/local/bin'
48+
}
49+
}
50+
} else {
51+
if $name == 'port' {
52+
# We need to force postgresql to stop before updating the port
53+
# because puppet becomes confused and is unable to manage the
54+
# service appropriately.
55+
exec { 'postgresql_stop':
56+
command => "service ${::postgresql::server::service_name} stop",
57+
onlyif => "service ${::postgresql::server::service_name} status",
58+
unless => "grep 'PGPORT=${value}' /etc/sysconfig/pgsql/postgresql",
59+
path => '/sbin:/bin:/usr/bin:/usr/local/bin',
60+
require => File['/etc/sysconfig/pgsql/postgresql'],
61+
} ->
62+
augeas { 'override PGPORT in /etc/sysconfig/pgsql/postgresql':
63+
lens => 'Shellvars.lns',
64+
incl => '/etc/sysconfig/pgsql/*',
65+
context => '/files/etc/sysconfig/pgsql/postgresql',
66+
changes => "set PGPORT ${value}",
67+
require => File['/etc/sysconfig/pgsql/postgresql'],
68+
notify => Class['postgresql::server::service'],
69+
before => Class['postgresql::server::reload'],
70+
}
3971
}
4072
}
4173
}

manifests/server/postgis.pp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
Package['postgresql-postgis']->
1818
Class['postgresql::server::service']->
1919
anchor { 'postgresql::server::postgis::end': }
20+
21+
if $postgresql::globals::manage_package_repo {
22+
Class['postgresql::repo'] ->
23+
Package['postgresql-postgis']
24+
}
2025
} else {
2126
anchor { 'postgresql::server::postgis::start': }->
2227
Class['postgresql::server::service']->

manifests/server/reload.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
command => "service ${service_name} reload",
1111
onlyif => $service_status,
1212
refreshonly => true,
13+
require => Class['postgresql::server::service'],
1314
}
1415
}
1516
}

manifests/server/service.pp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,25 @@
11
# PRIVATE CLASS: do not call directly
22
class postgresql::server::service {
33
$ensure = $postgresql::server::ensure
4+
$service_ensure = $postgresql::server::service_ensure
45
$service_name = $postgresql::server::service_name
56
$service_provider = $postgresql::server::service_provider
67
$service_status = $postgresql::server::service_status
78
$user = $postgresql::server::user
89
$port = $postgresql::server::port
910
$default_database = $postgresql::server::default_database
1011

11-
$service_ensure = $ensure ? {
12+
if $service_ensure {
13+
$real_service_ensure = $service_ensure
14+
} else {
15+
$real_service_ensure = $ensure ? {
16+
present => 'running',
17+
absent => 'stopped',
18+
default => $ensure
19+
}
20+
}
21+
22+
$service_enable = $ensure ? {
1223
present => true,
1324
absent => false,
1425
default => $ensure
@@ -17,15 +28,15 @@
1728
anchor { 'postgresql::server::service::begin': }
1829

1930
service { 'postgresqld':
20-
ensure => $service_ensure,
31+
ensure => $real_service_ensure,
2132
name => $service_name,
22-
enable => $service_ensure,
33+
enable => $service_enable,
2334
provider => $service_provider,
2435
hasstatus => true,
2536
status => $service_status,
2637
}
2738

28-
if($service_ensure) {
39+
if $real_service_ensure == 'running' {
2940
# This blocks the class before continuing if chained correctly, making
3041
# sure the service really is 'up' before continuing.
3142
#

spec/acceptance/postgis_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require 'spec_helper_acceptance'
22

3-
describe 'postgresql::server::postgis:' do
3+
describe 'postgresql::server::postgis:', :unless => fact('operatingsystem') == 'RedHat' && fact('operatingsystemrelease') == '7.0' do
44
after :all do
55
# Cleanup after tests have ran, remove both postgis and server as postgis
66
# pulls in the server based packages.
@@ -18,6 +18,7 @@ class { 'postgresql::server::postgis':
1818

1919
it 'test loading class with no parameters' do
2020
pp = <<-EOS.unindent
21+
class { 'postgresql::globals': manage_package_repo => true }
2122
class { 'postgresql::server': }
2223
class { 'postgresql::server::postgis': }
2324
EOS

0 commit comments

Comments
 (0)