Skip to content

Commit

Permalink
Copy server cert for Foreman Proxy using file resource
Browse files Browse the repository at this point in the history
  • Loading branch information
ehelms committed Apr 23, 2024
1 parent 38316a3 commit 18bd669
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions manifests/foreman_proxy.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,25 @@
$foreman_proxy_client_cert_name = "${hostname}-foreman-proxy-client"
$foreman_proxy_ssl_client_bundle = "${pki_dir}/private/${foreman_proxy_client_cert_name}-bundle.pem"

$proxy_cert_path = "${certs::ssl_build_dir}/${hostname}/${proxy_cert_name}"

if $server_cert {
cert { $proxy_cert_name:
ensure => present,
hostname => $hostname,
cname => $cname,
generate => $generate,
regenerate => $regenerate,
deploy => false,
custom_pubkey => $server_cert,
custom_privkey => $server_key,
custom_req => $server_cert_req,
build_dir => $certs::ssl_build_dir,
file { "${proxy_cert_path}.crt":
ensure => file,
source => $server_cert,
owner => 'root',
group => 'root',
mode => '0440',
}
file { "${proxy_cert_path}.key":
ensure => file,
source => $server_key,
owner => 'root',
group => 'root',
mode => '0440',
}

$require_cert = File["${proxy_cert_path}.crt"]
} else {
# cert for ssl of foreman-proxy
cert { $proxy_cert_name:
Expand All @@ -69,6 +75,8 @@
password_file => $ca_key_password_file,
build_dir => $certs::ssl_build_dir,
}

$require_cert = Cert[$proxy_cert_name]
}

# cert for authentication of foreman_proxy against foreman
Expand Down Expand Up @@ -101,7 +109,7 @@
cert_owner => $owner,
cert_group => $group,
cert_mode => $public_key_mode,
require => Cert[$proxy_cert_name],
require => $require_cert,
}

file { $proxy_ca_cert:
Expand Down

0 comments on commit 18bd669

Please sign in to comment.