Newer
Older
1
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
#
# Use:
#
# base::puppetclient::apply_credentials { '/etc/puppet/puppet.conf':
# template => '/etc/puppet/puppet.conf.template',
# }
#
define base::puppetclient::apply_credentials (
$template = 'NONE',
$target = $name,
$owner = 'root',
$group = 'root',
$mode = '0640',
) {
if ($template == "NONE") {
fail "cannot call base::puppetclient::apply_credentials without a template value"
}
# Need the database credentials.
include base::puppetclient::db_credentials
$config = $puppetclient::db_credentials::puppet_db_ini_file
## Put template together with DB credentials
exec { "generate-conf $target":
command => "generate-conf --template $template --config $config --newfile $target",
refreshonly => true,
subscribe => [
File[$template],
Base::Wallet[$puppetclient::db_credentials::credentials_wallet_name],
]
}
# Set file permissions
file { $target:
owner => $owner,
group => $group,
mode => $mode,
require => Exec["generate-conf $target"],
}
}