-
Notifications
You must be signed in to change notification settings - Fork 39
/
foreman.pp
66 lines (63 loc) · 2.15 KB
/
foreman.pp
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# Handles Foreman certs configuration
class certs::foreman (
Stdlib::Fqdn $hostname = $certs::node_fqdn,
Array[Stdlib::Fqdn] $cname = $certs::cname,
Boolean $generate = $certs::generate,
Boolean $regenerate = $certs::regenerate,
Boolean $deploy = $certs::deploy,
Stdlib::Absolutepath $client_cert = '/etc/foreman/client_cert.pem',
Stdlib::Absolutepath $client_key = '/etc/foreman/client_key.pem',
Stdlib::Absolutepath $ssl_ca_cert = '/etc/foreman/proxy_ca.pem',
String[2,2] $country = $certs::country,
String $state = $certs::state,
String $city = $certs::city,
String $org = 'FOREMAN',
String $org_unit = 'PUPPET',
String $expiration = $certs::expiration,
Stdlib::Absolutepath $ca_key_password_file = $certs::ca_key_password_file,
Stdlib::Absolutepath $server_ca = $certs::katello_server_ca_cert,
String $owner = 'root',
String $group = 'foreman',
) inherits certs {
$client_cert_name = "${hostname}-foreman-client"
$client_dn = "CN=${hostname}, OU=${org_unit}, O=${org}, ST=${state}, C=${country}"
# cert for authentication of puppetmaster against foreman
cert { $client_cert_name:
hostname => $hostname,
cname => $cname,
purpose => 'client',
country => $country,
state => $state,
city => $city,
org => $org,
org_unit => $org_unit,
expiration => $expiration,
ca => $certs::default_ca,
generate => $generate,
regenerate => $regenerate,
password_file => $ca_key_password_file,
build_dir => $certs::ssl_build_dir,
}
if $deploy {
certs::keypair { $client_cert_name:
source_dir => "${certs::ssl_build_dir}/${hostname}",
key_file => $client_key,
key_owner => $owner,
key_group => $group,
key_mode => '0440',
cert_file => $client_cert,
cert_owner => $owner,
cert_group => $group,
cert_mode => '0440',
require => Cert[$client_cert_name],
}
file { $ssl_ca_cert:
ensure => file,
source => $server_ca,
owner => 'root',
group => $group,
mode => '0440',
require => File[$server_ca],
}
}
}