2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'manifests/server/service.pp', line 2
class postgresql::server::service {
$service_ensure = $postgresql::server::service_ensure
$service_enable = $postgresql::server::service_enable
$service_manage = $postgresql::server::service_manage
$service_name = $postgresql::server::service_name
$service_provider = $postgresql::server::service_provider
$service_status = $postgresql::server::service_status
$user = $postgresql::server::user
$port = $postgresql::server::port
$default_database = $postgresql::server::default_database
$psql_path = $postgresql::server::psql_path
$connect_settings = $postgresql::server::default_connect_settings
anchor { 'postgresql::server::service::begin': }
if $service_manage {
service { 'postgresqld':
ensure => $service_ensure,
enable => $service_enable,
name => $service_name,
provider => $service_provider,
hasstatus => true,
status => $service_status,
}
if $service_ensure in ['running', true] {
# 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_conn_validator { 'validate_service_is_running':
run_as => $user,
db_name => $default_database,
port => $port,
connect_settings => $connect_settings,
sleep => 1,
tries => 60,
psql_path => $psql_path,
require => Service['postgresqld'],
before => Anchor['postgresql::server::service::end'],
}
Postgresql::Server::Database <| title == $default_database |> -> Postgresql_conn_validator['validate_service_is_running']
}
}
anchor { 'postgresql::server::service::end': }
}
|