From 5e334093427256ed4448253f2a7e50cc2da027a6 Mon Sep 17 00:00:00 2001 From: Ashley Penney Date: Thu, 8 May 2014 16:43:22 -0400 Subject: [PATCH] Add `service_ensure`. This allows you to control the status of the Postgresql service directly from postgresql::server. --- README.md | 13 +++++++++++-- manifests/params.pp | 1 + manifests/server.pp | 1 + manifests/server/service.pp | 29 ++++++++++++++++++++++------- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 13d66ef..fc21783 100644 --- a/README.md +++ b/README.md @@ -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 ------------ diff --git a/manifests/params.pp b/manifests/params.pp index 55a942e..4c9a6d2 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -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) diff --git a/manifests/server.pp b/manifests/server.pp index 5459327..a60b0ee 100644 --- a/manifests/server.pp +++ b/manifests/server.pp @@ -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, diff --git a/manifests/server/service.pp b/manifests/server/service.pp index aacbbc9..993ad23 100644 --- a/manifests/server/service.pp +++ b/manifests/server/service.pp @@ -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. #