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

Server 2.6 support #68

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ group :unit_tests do
gem 'rake', :require => false
gem 'rspec', '~> 3.1.0', :require => false
gem 'rspec-puppet', :require => false
gem 'puppetlabs_spec_helper', :require => false
gem 'puppet-lint', :require => false
gem 'puppetlabs_spec_helper', '~> 0.0', :require => false
gem 'puppet-lint', '~> 1.0', :require => false
gem 'puppet-syntax', :require => false
gem 'metadata-json-lint', :require => false
gem 'json', :require => false
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
String $puppetdb_version = $::puppet::params::puppetdb_version,
Boolean $manage_puppetdb = $::puppet::params::manage_puppetdb,
String $runinterval = $::puppet::params::runinterval,
String $server_bootstrap_dir = $::puppet::params::server_bootstrap_dir,
Boolean $server_ca_enabled = $::puppet::params::server_ca_enabled,
Optional[String] $server_certname = $::puppet::params::server_certname,
String $server_java_opts = $::puppet::params::server_java_opts,
Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
$runinterval = '30m'
$server_ca_enabled = true
$server_certname = undef
$server_bootstrap_dir = '/etc/puppetlabs/puppetserver/bootstrap.cfg'
$server_java_opts = '-Xms2g -Xmx2g'
$server_log_dir = '/var/log/puppetlabs/puppetserver'
$server_log_file = 'puppetserver.log'
Expand Down
34 changes: 33 additions & 1 deletion manifests/server/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
$manage_hiera = $::puppet::manage_hiera,
$hiera_source = $::puppet::hiera_source,
$java_opts = $::puppet::server_java_opts,
$bootstrap_dir = $::puppet::server_bootstrap_dir,
$log_dir = $::puppet::server_log_dir,
$log_file = $::puppet::server_log_file,
$server = $::puppet::server,
$server_version = $::puppet::server_version,
$runinterval = $::puppet::runinterval,
$puppetdb = $::puppet::puppetdb,
$puppetdb_port = $::puppet::puppetdb_port,
Expand Down Expand Up @@ -36,6 +38,35 @@
group => 'puppet',
}

case $server_version {
/(\d+\.\d+)\.\d+\-\d+.*/: {
$config = 0 + $1 # This must be a float
}
'latest': {
# There is a breaking confign change for version 2.6 and later.
$config = 2.6

}
default: {
$config = 2.5
}
}

if (
$config >= 2.6
) and (
$bootstrap_dir == $::puppet::params::server_bootstrap_dir
) {
$parsed_bootstrap_dir = '/etc/puppetlabs/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/'
$bootstrap_install_dir = '/opt/puppetlabs/server/apps/puppetserver/config/services.d'
} else {
$parsed_bootstrap_dir = $bootstrap_dir
$bootstrap_install_dir = '/etc/puppetlabs/puppetserver'
}




if $server {
file { $log_dir:
ensure => 'directory',
Expand All @@ -54,14 +85,15 @@
}

# Template uses
# - $parsed_bootstrap_dir
# - $java_opts
file { "${config_dir}/puppetserver":
content => template("${module_name}/server/puppetserver.sysconfig.erb"),
}

# Template uses
# - $ca_enabled
file { '/etc/puppetlabs/puppetserver/bootstrap.cfg':
file { "${bootstrap_install_dir}/bootstrap.cfg":
content => template("${module_name}/server/bootstrap.cfg.erb"),
}

Expand Down
46 changes: 40 additions & 6 deletions spec/classes/puppet_server_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
let(:pre_condition) { 'class { "puppet": }' }

it { should_not contain_concat__fragment('puppet_master') }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:ensure => 'absent') }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:ensure => 'absent') }
it { should contain_file('/etc/puppetlabs/puppetserver/logback.xml').with(:ensure => 'absent') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/ca.conf').with(:ensure => 'absent') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/global.conf').with(:ensure => 'absent') }
Expand Down Expand Up @@ -39,20 +39,49 @@
it { should_not contain_concat__fragment('puppet_master').with(:content => /reports/) }
it { should_not contain_concat__fragment('puppet_master').with( :content => /dns_alt_names/ ) }
it { should_not contain_concat__fragment('puppet_master').with(:content => /storeconfigs/) }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should_not contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
it { should contain_file('/etc/puppetlabs/puppetserver/logback.xml').with(:content => /<file>\/var\/log\/puppetlabs\/puppetserver\/puppetserver\.log<\/file>/) }
it { should contain_file('/etc/puppetlabs/puppetserver/request-logging.xml') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/ca.conf') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/global.conf') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf').with( :content => /max-active-instances: 3/ ) }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/puppetserver.conf').with( :content => /use-legacy-auth-conf: false/ ) }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/web-routes.conf') }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/webserver.conf') }
it { should contain_file('/etc/puppetlabs/code/hiera.yaml').with(:ensure => 'absent') }
it { should_not contain_firewall('500 allow inbound connections to puppetserver') }
end

context 'puppetserver 2.5 or earlier debian' do
let(:pre_condition) { 'class { "puppet": server => true, server_version => "2.4.0-1puppetlabs1"}' }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/web-routes.conf').without(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').without(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/)}
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should_not contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
end

context 'puppetserver 2.5 or earlier redhat' do
let(:pre_condition) { 'class { "puppet": server => true, server_version => "2.3.1-1.el7"}' }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/web-routes.conf').without(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').without(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/) }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should_not contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
end

context 'puppetserver 2.6 or later ' do
let(:pre_condition) { 'class { "puppet": server => true, server_version => "2.8.1-1.el7"}' }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/web-routes.conf').with(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should_not contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
end

context 'latest server on new install' do
let(:pre_condition) { 'class { "puppet": server => true}' }
it { should contain_file('/etc/puppetlabs/puppetserver/conf.d/web-routes.conf').with(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.trapperkeeper\.services\.status\.status\-service\/status\-service/ ) }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should_not contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
end

context 'redhat' do
let(:pre_condition) { 'class { "puppet": server => true}' }
it { should contain_file('/etc/sysconfig/puppetserver') }
Expand All @@ -64,15 +93,20 @@
it { should contain_file('/etc/default/puppetserver') }
end

context 'set bootstrap dir' do
let(:pre_condition) { 'class { "puppet": server => true, server_bootstrap_dir => "blah" }'}
it { should contain_file('/etc/sysconfig/puppetserver').with(:content => /BOOTSTRAP_CONFIG="blah"/) }
end

context 'set java opts' do
let(:pre_condition) { 'class { "puppet": server => true, server_java_opts => "blah" }'}
it { should contain_file('/etc/sysconfig/puppetserver').with(:content => /JAVA_ARGS="blah"/) }
end

context 'set disable ca' do
let(:pre_condition) { 'class { "puppet": server => true, server_ca_enabled => false }'}
it { should_not contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should contain_file('/etc/puppetlabs/puppetserver/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
it { should_not contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-service\/certificate\-authority\-service/) }
it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d/bootstrap.cfg').with(:content => /puppetlabs\.services\.ca\.certificate\-authority\-disabled\-service\/certificate\-authority\-disabled\-service/) }
it { should contain_concat__fragment('puppet_master').with(:content => /ca = false/) }
end

Expand Down
5 changes: 5 additions & 0 deletions templates/server/bootstrap.cfg.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ puppetlabs.services.ca.certificate-authority-service/certificate-authority-servi
<% else -%>
puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service
<% end -%>
<% if @config >= 2.6 -%>
puppetlabs.services.jruby-pool-manager.jruby-pool-manager-service/jruby-pool-manager-service
puppetlabs.trapperkeeper.services.scheduler.scheduler-service/scheduler-service
puppetlabs.trapperkeeper.services.status.status-service/status-service
<% end -%>
2 changes: 1 addition & 1 deletion templates/server/puppetserver.sysconfig.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ JAVA_ARGS="<%= @java_opts %>"
INSTALL_DIR="/opt/puppetlabs/server/apps/puppetserver"
JARFILE="server/apps/puppetserver/puppet-server-release.jar"
CONFIG="/etc/puppetlabs/puppetserver/conf.d"
BOOTSTRAP_CONFIG="/etc/puppetlabs/puppetserver/bootstrap.cfg"
BOOTSTRAP_CONFIG="<%= @parsed_bootstrap_dir %>"
USER="puppet"
GROUP="puppet"
SERVICE_STOP_RETRIES=60
Expand Down
6 changes: 6 additions & 0 deletions templates/server/web-routes.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,10 @@ web-router-service: {

# This controls the mount point for the puppet admin API.
"puppetlabs.services.puppet-admin.puppet-admin-service/puppet-admin-service": "/puppet-admin-api"

<% if @config >= 2.6 %>
# This controls the mount point for the status API
"puppetlabs.trapperkeeper.services.status.status-service/status-service": "/status"
<% end %>

}