module-postgresql/manifests/server/service.pp
Reid Vandewiele 6afb4a0367 Allow specification of default database name
E.g. pe-postgresql does NOT use postgres as the default database name.
It uses pe-postgres. So if there is no way to specify a default database
name, the postgesql::validate_db_connection resource in
postgresql::server::service will ALWAYS fail. This commit exposes the
parameter in order to avoid that situation.
2013-10-26 16:33:36 -07:00

40 lines
1.3 KiB
Puppet

# 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
$user = $postgresql::server::user
$default_database = $postgresql::server::default_database
$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,
}
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,
database_name => $default_database,
sleep => 1,
tries => 60,
create_db_first => false,
require => Service['postgresqld'],
}
}
}