Skip to content

Commit

Permalink
Make TLS authentication to foreman optional
Browse files Browse the repository at this point in the history
I hacked this for a customer some time ago. The customer has multiple
Puppet CAs and the foreman Web UI uses a certificate from a third CA. We
had to disable TLS client authentication to get the
puppetserver->foreman connection working.
  • Loading branch information
bastelfreak committed Feb 20, 2024
1 parent a83b960 commit b3d63ca
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
# The number of times to retry HTTP calls in the report processor
# @param puppet_basedir
# The directory used to install the report processor to
# @param use_client_tls_certs
# Enable client TLS authentication to foreman
class puppetserver_foreman (
Stdlib::HTTPUrl $foreman_url = $puppetserver_foreman::params::foreman_url,
Boolean $enc = true,
Expand All @@ -55,6 +57,7 @@
Variant[Enum[''], Stdlib::Absolutepath] $ssl_ca = $puppetserver_foreman::params::client_ssl_ca,
Variant[Enum[''], Stdlib::Absolutepath] $ssl_cert = $puppetserver_foreman::params::client_ssl_cert,
Variant[Enum[''], Stdlib::Absolutepath] $ssl_key = $puppetserver_foreman::params::client_ssl_key,
Boolean $use_client_tls_certs = true,
) inherits puppetserver_foreman::params {
case $facts['os']['family'] {
'Debian': { $json_package = 'ruby-json' }
Expand Down
8 changes: 8 additions & 0 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,14 @@
end
end

describe 'without TLS client authenticatio' do
let :params do
{ use_client_tls_certs: false }
end

it { is_expected.to contain_file("#{etc_dir}/foreman.yaml").without_content(%r{:ssl_(cert|key):}) }
end

describe 'without reports' do
let :params do
{ reports: false }
Expand Down
2 changes: 2 additions & 0 deletions templates/puppet.yaml.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
:url: "<%= @foreman_url %>"
:ssl_ca: "<%= @ssl_ca %>"
<% if @use_client_tls_certs -%>
:ssl_cert: "<%= @ssl_cert %>"
:ssl_key: "<%= @ssl_key %>"
<% end -%>
:puppetdir: "<%= @puppet_home %>"
:puppetuser: "<%= @puppet_user %>"
:facts: <%= @enc_upload_facts %>
Expand Down

0 comments on commit b3d63ca

Please sign in to comment.