Add service_ensure.

This allows you to control the status of the Postgresql service directly
from postgresql::server.
This commit is contained in:
Ashley Penney 2014-05-08 16:43:22 -04:00
parent 702998d8fd
commit 5e33409342
4 changed files with 35 additions and 9 deletions

View file

@ -288,6 +288,9 @@ This setting can be used to override the default postgresql PL/perl package name
####`python_package_name`
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.
####`service_ensure`
This setting can be used to override the default postgresql service ensure status. If not specified, the module will use `ensure` instead.
####`service_name`
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.
@ -837,11 +840,17 @@ Works with versions of PostgreSQL from 8.1 through 9.2.
Current it is only actively tested with the following operating systems:
* Debian 6.x and 7.x
* Centos 5.x and 6.x
* Ubuntu 10.04 and 12.04
* Centos 5.x, 6.x, and 7.x.
* Ubuntu 10.04 and 12.04, 14.04
Although patches are welcome for making it work with other OS distros, it is considered best effort.
### RHEL7
Currently the following features are unsupported:
* Postgis (There is no existing postgis package for RHEL7, and it's not in EPEL7 yet.)
Development
------------

View file

@ -11,6 +11,7 @@ class postgresql::params inherits postgresql::globals {
$ipv6acls = []
$encoding = $encoding
$locale = $locale
$service_ensure = undef
$service_provider = $service_provider
$manage_firewall = $manage_firewall
$manage_pg_hba_conf = pick($manage_pg_hba_conf, true)

View file

@ -10,6 +10,7 @@ class postgresql::server (
$plperl_package_name = $postgresql::params::plperl_package_name,
$service_ensure = $postgresql::params::service_ensure,
$service_name = $postgresql::params::service_name,
$service_provider = $postgresql::params::service_provider,
$service_status = $postgresql::params::service_status,

View file

@ -1,6 +1,7 @@
# PRIVATE CLASS: do not call directly
class postgresql::server::service {
$ensure = $postgresql::server::ensure
$service_ensure = $postgresql::server::service_ensure
$service_name = $postgresql::server::service_name
$service_provider = $postgresql::server::service_provider
$service_status = $postgresql::server::service_status
@ -8,24 +9,38 @@ class postgresql::server::service {
$port = $postgresql::server::port
$default_database = $postgresql::server::default_database
$service_ensure = $ensure ? {
present => true,
absent => false,
default => $ensure
if ! $service_ensure {
$real_service_ensure = $ensure ? {
present => true,
absent => false,
default => $ensure
}
$service_enable = $ensure ? {
present => true,
absent => false,
default => $ensure
}
} else {
$real_service_ensure = $service_ensure
$service_enable = $ensure ? {
present => true,
absent => false,
default => $ensure
}
}
anchor { 'postgresql::server::service::begin': }
service { 'postgresqld':
ensure => $service_ensure,
ensure => $real_service_ensure,
name => $service_name,
enable => $service_ensure,
enable => $service_enable,
provider => $service_provider,
hasstatus => true,
status => $service_status,
}
if($service_ensure) {
if $real_service_ensure == 'running' {
# This blocks the class before continuing if chained correctly, making
# sure the service really is 'up' before continuing.
#