2012-06-08 22:37:21 +02:00
|
|
|
# Class: postgresql::server
|
|
|
|
#
|
2012-11-09 22:29:05 +01:00
|
|
|
# == Class: postgresql::server
|
|
|
|
# Manages the installation of the postgresql server. manages the package and
|
|
|
|
# service.
|
2012-06-08 22:37:21 +02:00
|
|
|
#
|
2012-11-09 22:29:05 +01:00
|
|
|
# === Parameters:
|
|
|
|
# [*package_name*] - name of package
|
|
|
|
# [*service_name*] - name of service
|
2012-06-08 22:37:21 +02:00
|
|
|
#
|
|
|
|
# Actions:
|
|
|
|
#
|
|
|
|
# Requires:
|
|
|
|
#
|
|
|
|
# Sample Usage:
|
|
|
|
#
|
|
|
|
class postgresql::server (
|
2012-12-04 05:42:20 +01:00
|
|
|
$package_name = $postgresql::params::server_package_name,
|
2012-06-08 22:37:21 +02:00
|
|
|
$package_ensure = 'present',
|
2012-12-04 05:42:20 +01:00
|
|
|
$service_name = $postgresql::params::service_name,
|
|
|
|
$service_provider = $postgresql::params::service_provider,
|
|
|
|
$service_status = $postgresql::params::service_status,
|
2012-06-08 22:37:21 +02:00
|
|
|
$config_hash = {}
|
|
|
|
) inherits postgresql::params {
|
|
|
|
|
|
|
|
package { 'postgresql-server':
|
2012-11-09 22:29:05 +01:00
|
|
|
ensure => $package_ensure,
|
2012-12-04 05:42:20 +01:00
|
|
|
name => $package_name,
|
2012-06-08 22:37:21 +02:00
|
|
|
}
|
2012-12-03 08:06:36 +01:00
|
|
|
|
|
|
|
if defined(Yumrepo['yum.postgresql.org']) {
|
|
|
|
Yumrepo['yum.postgresql.org'] -> Package['postgresql-server']
|
|
|
|
}
|
2012-11-20 21:52:44 +01:00
|
|
|
|
2012-06-08 23:00:24 +02:00
|
|
|
$config_class = {}
|
|
|
|
$config_class['postgresql::config'] = $config_hash
|
|
|
|
|
|
|
|
create_resources( 'class', $config_class )
|
2012-11-20 21:52:44 +01:00
|
|
|
|
2012-06-08 22:37:21 +02:00
|
|
|
|
|
|
|
service { 'postgresqld':
|
|
|
|
ensure => running,
|
2012-12-04 05:42:20 +01:00
|
|
|
name => $service_name,
|
2012-06-08 22:37:21 +02:00
|
|
|
enable => true,
|
|
|
|
require => Package['postgresql-server'],
|
2012-12-04 05:42:20 +01:00
|
|
|
provider => $service_provider,
|
|
|
|
status => $service_status,
|
2012-06-08 22:37:21 +02:00
|
|
|
}
|
2012-12-03 07:05:57 +01:00
|
|
|
|
2012-11-20 21:52:44 +01:00
|
|
|
if ($postgresql::params::needs_initdb) {
|
|
|
|
include postgresql::initdb
|
|
|
|
|
|
|
|
Package['postgresql-server'] -> Class['postgresql::initdb'] -> Class['postgresql::config'] -> Service['postgresqld']
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Package['postgresql-server'] -> Class['postgresql::config'] -> Service['postgresqld']
|
|
|
|
}
|
2012-06-08 22:37:21 +02:00
|
|
|
|
2012-11-15 16:39:56 +01:00
|
|
|
exec { 'reload_postgresql':
|
|
|
|
path => '/usr/bin:/usr/sbin:/bin:/sbin',
|
2012-12-04 05:42:20 +01:00
|
|
|
command => "service ${service_name} reload",
|
2012-12-03 07:05:57 +01:00
|
|
|
user => $postgresql::params::user,
|
|
|
|
group => $postgresql::params::group,
|
2012-12-04 05:42:20 +01:00
|
|
|
onlyif => $service_status,
|
2012-11-09 23:46:16 +01:00
|
|
|
refreshonly => true,
|
|
|
|
}
|
2012-12-03 07:05:57 +01:00
|
|
|
|
2012-06-08 22:37:21 +02:00
|
|
|
}
|