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

Revert "use puppetlabs-hocon for webserver.conf" #620

Merged
merged 1 commit into from
Aug 16, 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
74 changes: 2 additions & 72 deletions manifests/server/puppetserver.pp
Original file line number Diff line number Diff line change
Expand Up @@ -274,79 +274,9 @@
content => template('puppet/server/puppetserver/conf.d/auth.conf.erb'),
}

$webserver_conf = "${server_puppetserver_dir}/conf.d/webserver.conf"

file { $webserver_conf:
file { "${server_puppetserver_dir}/conf.d/webserver.conf":
ensure => file,
}

$webserver_general_settings = {
'webserver.access-log-config' => "${server_puppetserver_dir}/request-logging.xml",
'webserver.client-auth' => 'want',
'webserver.ssl-host' => $server_ip,
'webserver.ssl-port' => $server_port,
'webserver.ssl-cert' => $server_ssl_cert,
'webserver.ssl-key' => $server_ssl_cert_key,
'webserver.ssl-ca-cert' => $server_ssl_ca_cert,
'webserver.idle-timeout-milliseconds' => $server_web_idle_timeout,
'webserver.ssl-protocols' => $server_ssl_protocols,
'webserver.cipher-suites' => $server_cipher_suites,
}

$webserver_general_settings.each |$setting, $value| {
hocon_setting { $setting:
ensure => present,
path => $webserver_conf,
setting => $setting,
value => $value,
require => File[$webserver_conf],
}
}

$webserver_http_settings_ensure = $server_http ? {
true => present,
default => absent,
}

$webserver_http_settings = {
'webserver.host' => $server_ip,
'webserver.port' => $server_http_port,
}

$webserver_http_settings.each |$setting, $value| {
hocon_setting { $setting:
ensure => $webserver_http_settings_ensure,
path => $webserver_conf,
setting => $setting,
value => $value,
require => File[$webserver_conf],
}
}

$webserver_crl_settings_ensure = $server_crl_enable ? {
true => present,
default => absent,
}

hocon_setting { 'webserver.ssl-crl-path':
ensure => $webserver_crl_settings_ensure,
path => $webserver_conf,
setting => 'webserver.ssl-crl-path',
value => $server_ssl_ca_crl,
require => File[$webserver_conf],
}

$webserver_ca_settings_ensure = $server_ca ? {
true => present,
default => absent,
}

hocon_setting { 'webserver.ssl-cert-chain':
ensure => $webserver_ca_settings_ensure,
path => $webserver_conf,
setting => 'webserver.ssl-cert-chain',
value => $server_ssl_chain,
require => File[$webserver_conf],
content => template('puppet/server/puppetserver/conf.d/webserver.conf.erb'),
}

if versioncmp($server_puppetserver_version, '2.7') >= 0 {
Expand Down
69 changes: 21 additions & 48 deletions spec/classes/puppet_server_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -723,11 +723,8 @@
end

it 'should use the ca_crl.pem file' do
should contain_hocon_setting('webserver.ssl-crl-path').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-crl-path').
with_value("#{ssldir}/ca/ca_crl.pem").
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ssl-crl-path: #{ssldir}\/ca\/ca_crl.pem/)
end
end

Expand All @@ -743,10 +740,8 @@
end

it 'should use the ca_crl.pem file' do
should contain_hocon_setting('webserver.ssl-crl-path').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-crl-path').
with_ensure('absent')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
without_content(/ssl-crl-path: #{ssldir}\/crl.pem/)
end
end
context 'as non-ca with server_crl_enable' do
Expand All @@ -761,11 +756,8 @@
}"
end
it 'should use the crl.pem file' do
should contain_hocon_setting('webserver.ssl-crl-path').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-crl-path').
with_value("#{ssldir}/crl.pem").
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ssl-crl-path: #{ssldir}\/crl.pem/)
end
end
end
Expand All @@ -782,11 +774,8 @@
end

it 'should set the ssl protocols' do
should contain_hocon_setting('webserver.ssl-protocols').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-protocols').
with_value(['TLSv1.1', 'TLSv1.2']).
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ssl-protocols: \[\n( +)TLSv1.1,\n( +)TLSv1.2,\n( +)\]/)
end
end

Expand All @@ -802,11 +791,8 @@
end

it 'should set the cipher suite' do
should contain_hocon_setting('webserver.cipher-suites').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.cipher-suites').
with_value(['TLS_RSA_WITH_AES_256_CBC_SHA256', 'TLS_RSA_WITH_AES_256_CBC_SHA']).
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/cipher-suites: \[\n( +)TLS_RSA_WITH_AES_256_CBC_SHA256,\n( +)TLS_RSA_WITH_AES_256_CBC_SHA,\n( +)\]/)
end
end

Expand All @@ -824,11 +810,8 @@
end

it 'should use the server_ssl_chain_filepath file' do
should contain_hocon_setting('webserver.ssl-cert-chain').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-cert-chain').
with_value('/etc/example/certchain.pem').
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ssl-cert-chain: \/etc\/example\/certchain.pem/)
end
end

Expand All @@ -843,11 +826,7 @@
end

it 'should put the correct ip address in webserver.conf' do
should contain_hocon_setting('webserver.ssl-host').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-host').
with_value('127.0.0.1').
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').with_content(/ssl-host:\s127\.0\.0\.1/)
end
end

Expand All @@ -863,19 +842,13 @@
end

it 'should put the correct ssl key path in webserver.conf' do
should contain_hocon_setting('webserver.ssl-key').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-key').
with_value('/etc/custom/puppet/ssl/private_keys/puppetserver43.example.com.pem').
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(%r{ssl-key: /etc/custom/puppet/ssl/private_keys/puppetserver43\.example\.com\.pem})
end

it 'should put the correct ssl cert path in webserver.conf' do
should contain_hocon_setting('webserver.ssl-cert').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-cert').
with_value('/etc/custom/puppet/ssl/certs/puppetserver43.example.com.pem').
with_ensure('present')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(%r{ssl-cert: /etc/custom/puppet/ssl/certs/puppetserver43\.example\.com\.pem})
end
end

Expand All @@ -890,10 +863,10 @@
end

it do
should contain_hocon_setting('webserver.host').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.host').
with_value('0.0.0.0')
should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ host:\s0\.0\.0\.0/).
with_content(/ port:\s8139/).
with({})
end

it { should contain_file('/etc/custom/puppetserver/conf.d/auth.conf').
Expand Down
21 changes: 6 additions & 15 deletions spec/classes/puppet_server_puppetserver_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,22 +124,13 @@
without_content(/^\s+"puppetserver123.example.com"\,$/).
with({}) # So we can use a trailing dot on each with_content line
}
it {
should contain_hocon_setting('webserver.ssl-host').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-host').
with_value('0.0.0.0').
with_ensure('present')
}
it {
should contain_hocon_setting('webserver.ssl-port').
with_path('/etc/custom/puppetserver/conf.d/webserver.conf').
with_setting('webserver.ssl-port').
with_value('8140').
with_ensure('present')
it { should contain_file('/etc/custom/puppetserver/conf.d/webserver.conf').
with_content(/ssl-host:\s0\.0\.0\.0/).
with_content(/ssl-port:\s8140/).
without_content(/ host:\s/).
without_content(/ port:\s8139/).
with({})
}
it { should contain_hocon_setting('webserver.host').with_ensure('absent') }
it { should contain_hocon_setting('webserver.port').with_ensure('absent') }
it {
should contain_file('/etc/custom/puppetserver/conf.d/auth.conf').
with_content(/allow-header-cert-info: false/).
Expand Down
30 changes: 30 additions & 0 deletions templates/server/puppetserver/conf.d/webserver.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
webserver: {
access-log-config: <%= @server_puppetserver_dir %>/request-logging.xml
client-auth: want
<%- if @server_http -%>
host: <%= @server_ip %>
port: <%= @server_http_port %>
<%- end -%>
ssl-host: <%= @server_ip %>
ssl-port: <%= @server_port %>
ssl-cert: <%= @server_ssl_cert %>
ssl-key: <%= @server_ssl_cert_key %>
ssl-ca-cert: <%= @server_ssl_ca_cert %>
<%- if @server_crl_enable -%>
ssl-crl-path: <%= @server_ssl_ca_crl %>
<%- end -%>
<%- if @server_ca -%>
ssl-cert-chain: <%= @server_ssl_chain %>
<%- end -%>
idle-timeout-milliseconds: <%= @server_web_idle_timeout %>
ssl-protocols: [
<%- @server_ssl_protocols.each do |ssl_protocol| -%>
<%= ssl_protocol %>,
<%- end -%>
]
cipher-suites: [
<%- @server_cipher_suites.each do |cipher_suite| -%>
<%= cipher_suite %>,
<%- end -%>
]
}