2013-08-27 22:43:47 +02:00
|
|
|
# PRIVATE CLASS: do not call directly
|
|
|
|
class postgresql::server::service {
|
|
|
|
$ensure = $postgresql::server::ensure
|
|
|
|
$service_name = $postgresql::server::service_name
|
|
|
|
$service_provider = $postgresql::server::service_provider
|
|
|
|
$service_status = $postgresql::server::service_status
|
2013-10-23 23:49:16 +02:00
|
|
|
$user = $postgresql::server::user
|
2013-10-26 23:47:32 +02:00
|
|
|
$default_database = $postgresql::server::default_database
|
2013-08-27 22:43:47 +02:00
|
|
|
|
|
|
|
$service_ensure = $ensure ? {
|
|
|
|
present => true,
|
|
|
|
absent => false,
|
|
|
|
default => $ensure
|
|
|
|
}
|
|
|
|
|
|
|
|
service { 'postgresqld':
|
|
|
|
ensure => $service_ensure,
|
|
|
|
name => $service_name,
|
|
|
|
enable => $service_ensure,
|
|
|
|
provider => $service_provider,
|
|
|
|
hasstatus => true,
|
|
|
|
status => $service_status,
|
|
|
|
}
|
2013-10-23 23:49:16 +02:00
|
|
|
|
|
|
|
if($service_ensure) {
|
|
|
|
# This blocks the class before continuing if chained correctly, making
|
|
|
|
# sure the service really is 'up' before continuing.
|
|
|
|
#
|
|
|
|
# Without it, we may continue doing more work before the database is
|
|
|
|
# prepared leading to a nasty race condition.
|
|
|
|
postgresql::validate_db_connection { 'validate_service_is_running':
|
|
|
|
run_as => $user,
|
2013-10-26 23:47:32 +02:00
|
|
|
database_name => $default_database,
|
2013-10-23 23:49:16 +02:00
|
|
|
sleep => 1,
|
2013-10-24 01:33:00 +02:00
|
|
|
tries => 60,
|
2013-10-23 23:49:16 +02:00
|
|
|
create_db_first => false,
|
|
|
|
require => Service['postgresqld'],
|
|
|
|
}
|
|
|
|
}
|
2013-08-27 22:43:47 +02:00
|
|
|
}
|