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

Refs #24012 - Add PuppetCA providers settings #435

Merged
merged 1 commit into from
Jun 26, 2018
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
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ Part of the Foreman installer: <https://github.com/theforeman/foreman-installer>

| Module version | Proxy versions | Notes |
|----------------|----------------|-------------------------------------------------|
| 5.x | 1.16 and newer | |
| 5.x | 1.16 and newer | See compatibility notes here for 1.16-1.18 |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ekohl Version 5? What about 6,7,8 and 9?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 5.x and newer. The breaking changes have been for different reasons than compatibility. Untested, but I think 9 should still allow managing 1.16. It'd be good to be explicit about this though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in current master

| 4.x | 1.12 - 1.17 | See compatibility notes in its README for 1.15+ |
| 3.x | 1.11 | |
| 2.x | 1.5 - 1.10 | |
| 1.x | 1.4 and older | |

### Compatibility notes for Smart Proxy < 1.18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be < 1.19?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right.


On Smart Proxy 1.16, 1.17 & 1.18, also set

```puppet
puppetca_modular => false,
```

to ensure that it only uses the `puppetca.yml` configuration not the provider settings files.


## Examples

### Minimal setup for Puppet/PuppetCA Smart Proxy
Expand Down
7 changes: 7 additions & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@
feature => 'Puppet CA',
listen_on => $::foreman_proxy::puppetca_listen_on,
}
if $::foreman_proxy::puppetca_modular {
foreman_proxy::settings_file { [
'puppetca_hostname_whitelisting',
]:
module => false,
}
}
foreman_proxy::settings_file { 'realm':
enabled => $::foreman_proxy::realm,
feature => 'Realm',
Expand Down
8 changes: 7 additions & 1 deletion manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#
# $puppet_group:: Groups of Foreman proxy user
#
# $autosignfile:: Path to the autosign file
# $autosignfile:: Hostname-Whitelisting only: Location of puppets autosign.conf
#
# $manage_puppet_group:: Whether to ensure the $puppet_group exists. Also ensures group owner of ssl keys and certs is $puppet_group
# Not applicable when ssl is false.
Expand Down Expand Up @@ -291,6 +291,10 @@
#
# $dhcp_manage_acls:: Whether to manage DHCP directory ACLs. This allows the Foreman Proxy user to access even if the directory mode is 0750.
#
# $puppetca_modular:: Whether the PuppetCa implementation is modular. This is true for 1.19 or later.
#
# $puppetca_provider:: Whether to use puppetca_hostname_whitelisting or puppetca_token_whitelisting
#
class foreman_proxy (
String $repo = $::foreman_proxy::params::repo,
Boolean $gpgcheck = $::foreman_proxy::params::gpgcheck,
Expand Down Expand Up @@ -328,6 +332,8 @@
Stdlib::Absolutepath $puppetdir = $::foreman_proxy::params::puppetdir,
String $puppetca_cmd = $::foreman_proxy::params::puppetca_cmd,
String $puppet_group = $::foreman_proxy::params::puppet_group,
Boolean $puppetca_modular = $::foreman_proxy::params::puppetca_modular,
String $puppetca_provider = $::foreman_proxy::params::puppetca_provider,
Stdlib::Absolutepath $autosignfile = $::foreman_proxy::params::autosignfile,
Boolean $manage_puppet_group = $::foreman_proxy::params::manage_puppet_group,
Boolean $puppet = $::foreman_proxy::params::puppet,
Expand Down
12 changes: 7 additions & 5 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,13 @@
$puppet_api_timeout = 30

# puppetca settings
$puppetca = true
$puppetca_listen_on = 'https'
$puppetca_cmd = "${puppet_cmd} cert"
$puppet_group = 'puppet'
$autosignfile = "${puppetdir}/autosign.conf"
$puppetca = true
$puppetca_modular = true
$puppetca_provider = 'puppetca_hostname_whitelisting'
$puppetca_listen_on = 'https'
$puppetca_cmd = "${puppet_cmd} cert"
$puppet_group = 'puppet'
$autosignfile = "${puppetdir}/autosign.conf"

# The puppet-agent package, (puppet 4 AIO) doesn't create a puppet group
$manage_puppet_group = versioncmp($::puppetversion, '4.0') > 0
Expand Down
32 changes: 31 additions & 1 deletion spec/classes/foreman_proxy__config__spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@
'settings.d/dns_nsupdate.yml', 'settings.d/dns_nsupdate_gss.yml',
'settings.d/dns_libvirt.yml', 'settings.d/dhcp.yml', 'settings.d/dhcp_isc.yml',
'settings.d/dhcp_libvirt.yml', 'settings.d/logs.yml', 'settings.d/puppet.yml',
'settings.d/puppetca.yml', 'settings.d/puppet_proxy_customrun.yml',
'settings.d/puppetca.yml', 'settings.d/puppetca_hostname_whitelisting.yml',
'settings.d/puppet_proxy_customrun.yml',
'settings.d/puppet_proxy_legacy.yml', 'settings.d/puppet_proxy_mcollective.yml',
'settings.d/puppet_proxy_puppet_api.yml', 'settings.d/puppet_proxy_puppetrun.yml',
'settings.d/puppet_proxy_salt.yml', 'settings.d/puppet_proxy_ssh.yml',
Expand Down Expand Up @@ -252,7 +253,14 @@
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppetca.yml", [
'---',
':enabled: https',
':use_provider: puppetca_hostname_whitelisting',
":ssldir: #{ssl_dir}",
])
end

it 'should generate correct puppetca_hostname_whitelisting.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppetca_hostname_whitelisting.yml", [
'---',
":autosignfile: #{puppet_etc_dir}/autosign.conf",
])
end
Expand Down Expand Up @@ -775,6 +783,28 @@
end
end

context 'using the non-modular legacy puppetca' do
let :pre_condition do
'class { "foreman_proxy":
puppetca_modular => false,
autosignfile => "/bar/baz.conf",
}'
end

it 'should generate correct puppetca.yml' do
verify_exact_contents(catalogue, "#{etc_dir}/foreman-proxy/settings.d/puppetca.yml", [
'---',
':enabled: https',
":ssldir: #{ssl_dir}",
":autosignfile: /bar/baz.conf",
])
end

it 'should not generate a puppetca_hostname_whitelisting' do
should_not contain_file("#{etc_dir}/foreman-proxy/settings.d/puppet_hostname_whitelisting")
end
end

context 'when puppetrun_provider and puppetrun_cmd set' do
let :pre_condition do
'class { "foreman_proxy":
Expand Down
4 changes: 4 additions & 0 deletions templates/puppetca.yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@
# PuppetCA management
:enabled: <%= @module_enabled %>
:ssldir: <%= scope.lookupvar("foreman_proxy::ssldir") %>
<% if scope.lookupvar("foreman_proxy::puppetca_modular") -%>
:use_provider: <%= scope.lookupvar("foreman_proxy::puppetca_provider") %>
<% else -%>
:autosignfile: <%= scope.lookupvar("foreman_proxy::autosignfile") %>
<% end -%>
6 changes: 6 additions & 0 deletions templates/puppetca_hostname_whitelisting.yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
#
# Configuration of the PuppetCA hostname_whitelisting provider
#

:autosignfile: <%= scope.lookupvar('foreman_proxy::autosignfile') %>