Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TLS authentication to foreman optional #39

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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