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
50
51
52
53
54
55
56
57
58
59
|
# File 'plans/util/update_db_setting.pp', line 5
plan peadm::util::update_db_setting (
TargetSpec $targets,
Optional[Peadm::SingleTargetSpec] $postgresql_host = undef,
Optional[Hash] $peadm_config = undef,
Boolean $override = false
) {
# FIX ME: Section needs to be parallelized, can't use built in functionality
# of apply().
get_targets($targets).each |$target| {
if $override {
$db = $postgresql_host
} else {
# Existing config used to dynamically pair nodes with appropriate PSQL
# server
$roles = $peadm_config['role-letter']
# Determine configuration by pairing target with existing availability letter
# assignments, setting to the new node if no match is found.
$target_group_letter = peadm::flatten_compact([$roles['compilers'],$roles['server']].map |$role| {
$role.map |$k,$v| {
if $target.peadm::certname() in $v { $k }
}
})[0]
$match = $roles['postgresql'][$target_group_letter]
if $match {
$db = $match
} else {
$db = $postgresql_host
}
}
$db_setting = "//${db}:5432/pe-puppetdb?ssl=true&sslfactory=org.postgresql.ssl.jdbc4.LibPQFactory&sslmode=verify-full&sslrootcert=/etc/puppetlabs/puppet/ssl/certs/ca.pem&sslkey=/etc/puppetlabs/puppetdb/ssl/${target.peadm::certname()}.private_key.pk8&sslcert=/etc/puppetlabs/puppetdb/ssl/${$target.peadm::certname()}.cert.pem" # lint:ignore:140chars
# Introduces dependency so PEADM can modify INI files
apply($target) {
ini_setting { 'database_setting':
ensure => present,
path => '/etc/puppetlabs/puppetdb/conf.d/database.ini',
section => 'database',
setting => 'subname',
value => $db_setting,
}
ini_setting { 'read_database_setting':
ensure => present,
path => '/etc/puppetlabs/puppetdb/conf.d/read_database.ini',
section => 'read-database',
setting => 'subname',
value => $db_setting,
}
}
}
return('PuppetDB database settings were updated successfully.')
}
|