diff --git a/manifests/server/puppetserver.pp b/manifests/server/puppetserver.pp index 2dccbd9a..502829e7 100644 --- a/manifests/server/puppetserver.pp +++ b/manifests/server/puppetserver.pp @@ -132,8 +132,8 @@ ) { include ::puppet::server - if versioncmp($server_puppetserver_version, '2.2') < 0 { - fail('puppetserver <2.2 is not supported by this module version') + if versioncmp($server_puppetserver_version, '2.7') < 0 { + fail('puppetserver <2.7 is not supported by this module version') } $puppetserver_package = pick($::puppet::server::package, 'puppetserver') @@ -167,13 +167,7 @@ changes => $changes, } - if versioncmp($server_puppetserver_version, '2.4.99') == 0 { - $bootstrap_paths = "${server_puppetserver_dir}/bootstrap.cfg,${server_puppetserver_dir}/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/" - } elsif versioncmp($server_puppetserver_version, '2.5') >= 0 { - $bootstrap_paths = "${server_puppetserver_dir}/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/" - } else { # 2.4 - $bootstrap_paths = "${server_puppetserver_dir}/bootstrap.cfg" - } + $bootstrap_paths = "${server_puppetserver_dir}/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/" if versioncmp($server_puppetserver_version, '5.3') >= 0 { $server_gem_paths = [ '${jruby-puppet.gem-home}', "\"${server_puppetserver_vardir}/vendored-jruby-gems\"", "\"/opt/puppetlabs/puppet/lib/ruby/vendor_gems\""] # lint:ignore:single_quote_string_with_variables @@ -203,69 +197,21 @@ } } - # 2.4.99 configures for both 2.4 and 2.5 making upgrades and new installations easier when the - # precise version available isn't known - if versioncmp($server_puppetserver_version, '2.4.99') >= 0 { - $servicesd = "${server_puppetserver_dir}/services.d" - file { $servicesd: - ensure => directory, - } - file { "${servicesd}/ca.cfg": - ensure => file, - content => template('puppet/server/puppetserver/services.d/ca.cfg.erb'), - } - - unless $::osfamily == 'FreeBSD' { - file { '/opt/puppetlabs/server/apps/puppetserver/config': - ensure => directory, - } - file { '/opt/puppetlabs/server/apps/puppetserver/config/services.d': - ensure => directory, - } - } + $servicesd = "${server_puppetserver_dir}/services.d" + file { $servicesd: + ensure => directory, + } + file { "${servicesd}/ca.cfg": + ensure => file, + content => template('puppet/server/puppetserver/services.d/ca.cfg.erb'), } - if versioncmp($server_puppetserver_version, '2.5') < 0 { - $bootstrapcfg = "${server_puppetserver_dir}/bootstrap.cfg" - file { $bootstrapcfg: - ensure => file, - } - - $ca_enabled_ensure = $server_ca ? { - true => present, - default => absent, - } - - $ca_disabled_ensure = $server_ca ? { - false => present, - default => absent, - } - - file_line { 'ca_enabled': - ensure => $ca_enabled_ensure, - path => $bootstrapcfg, - line => 'puppetlabs.services.ca.certificate-authority-service/certificate-authority-service', - require => File[$bootstrapcfg], - } - - file_line { 'ca_disabled': - ensure => $ca_disabled_ensure, - path => $bootstrapcfg, - line => 'puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service', - require => File[$bootstrapcfg], - } - - if versioncmp($server_puppetserver_version, '2.3') >= 0 { - $versioned_code_service_ensure = present - } else { - $versioned_code_service_ensure = absent + unless $::osfamily == 'FreeBSD' { + file { '/opt/puppetlabs/server/apps/puppetserver/config': + ensure => directory, } - - file_line { 'versioned_code_service': - ensure => $versioned_code_service_ensure, - path => $bootstrapcfg, - line => 'puppetlabs.services.versioned-code-service.versioned-code-service/versioned-code-service', - require => File[$bootstrapcfg], + file { '/opt/puppetlabs/server/apps/puppetserver/config/services.d': + ensure => directory, } } @@ -295,14 +241,8 @@ content => template('puppet/server/puppetserver/conf.d/webserver.conf.erb'), } - if versioncmp($server_puppetserver_version, '2.7') >= 0 { - $product_conf_ensure = file - } else { - $product_conf_ensure = absent - } - file { "${server_puppetserver_dir}/conf.d/product.conf": - ensure => $product_conf_ensure, + ensure => file, content => template('puppet/server/puppetserver/conf.d/product.conf.erb'), } diff --git a/spec/acceptance/puppetserver_upgrade_2_6_0_to_2_7_2_spec.rb b/spec/acceptance/puppetserver_upgrade_2_6_0_to_2_7_2_spec.rb index 632f1911..29dceef3 100644 --- a/spec/acceptance/puppetserver_upgrade_2_6_0_to_2_7_2_spec.rb +++ b/spec/acceptance/puppetserver_upgrade_2_6_0_to_2_7_2_spec.rb @@ -15,14 +15,14 @@ case fact('osfamily') when 'Debian' - from_version = '2.6.0-1puppetlabs1' + from_version = '2.7.0-1puppetlabs1' to_version = '2.7.2-1puppetlabs1' else - from_version = '2.6.0' + from_version = '2.7.0' to_version = '2.7.2' end - context 'install 2.6.0' do + context 'install 2.7.0' do let(:pp) do <<-EOS class { '::puppet': @@ -42,7 +42,7 @@ class { '::puppet': it_behaves_like 'a idempotent resource' describe command('puppetserver --version') do - its(:stdout) { is_expected.to match("puppetserver version: 2.6.0\n") } + its(:stdout) { is_expected.to match("puppetserver version: 2.7.0\n") } end describe service('puppetserver') do diff --git a/spec/classes/puppet_server_puppetserver_spec.rb b/spec/classes/puppet_server_puppetserver_spec.rb index 856de8f7..088322ee 100644 --- a/spec/classes/puppet_server_puppetserver_spec.rb +++ b/spec/classes/puppet_server_puppetserver_spec.rb @@ -21,14 +21,11 @@ server_jvm_extra_args: '', server_max_active_instances: 2, server_puppetserver_dir: '/etc/custom/puppetserver', - server_puppetserver_version: '2.4.99', + server_puppetserver_version: '2.7.0', } end describe 'with default parameters' do - it { should contain_file('/etc/custom/puppetserver/bootstrap.cfg') } - it { should contain_file_line('ca_enabled').with_ensure('present') } - it { should contain_file_line('ca_disabled').with_ensure('absent') } it { should contain_file('/etc/custom/puppetserver/services.d').with_ensure('directory') } it { should contain_file('/etc/custom/puppetserver/services.d/ca.cfg') @@ -47,7 +44,7 @@ it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d').with_ensure('directory') } it { should contain_augeas('puppet::server::puppetserver::bootstrap') - .with_changes('set BOOTSTRAP_CONFIG \'"/etc/custom/puppetserver/bootstrap.cfg,/etc/custom/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"\'') + .with_changes('set BOOTSTRAP_CONFIG \'"/etc/custom/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"\'') } it { @@ -125,11 +122,6 @@ let(:params) { super().merge(server_environment_class_cache_enabled: true) } it { should contain_file(puppetserver_conf).with_content(/^ environment-class-cache-enabled: true$/) } end - - context 'when server_puppetserver_version < 2.4' do - let(:params) { super().merge(server_puppetserver_version: '2.2.2') } - it { should contain_file(puppetserver_conf).without_content('environment-class-cache-enabled') } - end end describe 'server_max_requests_per_instance' do @@ -158,7 +150,6 @@ end context 'when server_puppetserver_version < 5.0 with default parameters' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } it { should contain_file(puppetserver_conf).without_content('max-queued-requests') } end end @@ -178,106 +169,31 @@ end context 'when server_puppetserver_version < 5.0 with default parameters' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } it { should contain_file(puppetserver_conf).without_content('max-retry-delay') } end end - describe 'versioned-code-service' do - context 'when server_puppetserver_version >= 2.5' do - let(:params) { super().merge(server_puppetserver_version: '2.5.0') } - it { should_not contain_file_line('versioned_code_service') } - end - - context 'when server_puppetserver_version >= 2.3 and < 2.5' do - let(:params) { super().merge(server_puppetserver_version: '2.3.1') } - it 'should have versioned-code-service in bootstrap.cfg' do - should contain_file_line('versioned_code_service') - .with_ensure('present') - .with_path('/etc/custom/puppetserver/bootstrap.cfg') - .with_line('puppetlabs.services.versioned-code-service.versioned-code-service/versioned-code-service') - .that_requires('File[/etc/custom/puppetserver/bootstrap.cfg]') - end - end - - context 'when server_puppetserver_version < 2.3' do - let(:params) { super().merge(server_puppetserver_version: '2.2.2') } - it 'should not have versioned-code-service in bootstrap.cfg' do - should contain_file_line('versioned_code_service') - .with_ensure('absent') - .with_path('/etc/custom/puppetserver/bootstrap.cfg') - .with_line('puppetlabs.services.versioned-code-service.versioned-code-service/versioned-code-service') - .that_requires('File[/etc/custom/puppetserver/bootstrap.cfg]') - end - end - end - - describe 'bootstrap.cfg' do - context 'when server_puppetserver_version >= 2.5' do - let(:params) { super().merge(server_puppetserver_version: '2.5.0') } - it { should_not contain_file('/etc/custom/puppetserver/bootstrap.cfg') } - it { should_not contain_file_line('ca_enabled') } - it { should_not contain_file_line('ca_disabled') } - end - - context 'when server_puppetserver_version < 2.4.99' do - let(:params) { super().merge(server_puppetserver_version: '2.4.98') } - it { should contain_file('/etc/custom/puppetserver/bootstrap.cfg') } - it { - should contain_file_line('ca_enabled') - .with_ensure('present') - .with_path('/etc/custom/puppetserver/bootstrap.cfg') - .with_line('puppetlabs.services.ca.certificate-authority-service/certificate-authority-service') - .that_requires('File[/etc/custom/puppetserver/bootstrap.cfg]') - } - it { - should contain_file_line('ca_disabled') - .with_ensure('absent') - .with_path('/etc/custom/puppetserver/bootstrap.cfg') - .with_line('puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service') - .that_requires('File[/etc/custom/puppetserver/bootstrap.cfg]') - } - unless facts[:osfamily] == 'FreeBSD' - it { - should contain_augeas('puppet::server::puppetserver::bootstrap') - .with_changes('set BOOTSTRAP_CONFIG \'"/etc/custom/puppetserver/bootstrap.cfg"\'') - .with_context('/files/etc/default/puppetserver') - .with_incl('/etc/default/puppetserver') - .with_lens('Shellvars.lns') - } - end - end - end - describe 'ca.cfg' do - context 'when server_puppetserver_version >= 2.5' do - let(:params) { super().merge(server_puppetserver_version: '2.5.0') } - it { should contain_file('/etc/custom/puppetserver/services.d').with_ensure('directory') } + it { should contain_file('/etc/custom/puppetserver/services.d').with_ensure('directory') } + it { + should contain_file('/etc/custom/puppetserver/services.d/ca.cfg') + .with_content(%r{^puppetlabs.services.ca.certificate-authority-service/certificate-authority-service}) + .with_content(%r{^#puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service}) + } + unless facts[:osfamily] == 'FreeBSD' + it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config').with_ensure('directory') } + it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d').with_ensure('directory') } it { - should contain_file('/etc/custom/puppetserver/services.d/ca.cfg') - .with_content(%r{^puppetlabs.services.ca.certificate-authority-service/certificate-authority-service}) - .with_content(%r{^#puppetlabs.services.ca.certificate-authority-disabled-service/certificate-authority-disabled-service}) + should contain_augeas('puppet::server::puppetserver::bootstrap') + .with_changes('set BOOTSTRAP_CONFIG \'"/etc/custom/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"\'') + .with_context('/files/etc/default/puppetserver') + .with_incl('/etc/default/puppetserver') + .with_lens('Shellvars.lns') } - unless facts[:osfamily] == 'FreeBSD' - it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config').with_ensure('directory') } - it { should contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d').with_ensure('directory') } - it { - should contain_augeas('puppet::server::puppetserver::bootstrap') - .with_changes('set BOOTSTRAP_CONFIG \'"/etc/custom/puppetserver/services.d/,/opt/puppetlabs/server/apps/puppetserver/config/services.d/"\'') - .with_context('/files/etc/default/puppetserver') - .with_incl('/etc/default/puppetserver') - .with_lens('Shellvars.lns') - } - end end - context 'when server_puppetserver_version >= 2.5 and server_ca => false' do - let(:params) do - super().merge( - server_puppetserver_version: '2.5.0', - server_ca: false - ) - end + context 'when server_ca => false' do + let(:params) { super().merge(server_ca: false) } it { should contain_file('/etc/custom/puppetserver/services.d/ca.cfg') .with_content(%r{^#puppetlabs.services.ca.certificate-authority-service/certificate-authority-service}) @@ -285,14 +201,6 @@ } end - context 'when server_puppetserver_version < 2.4.99' do - let(:params) { super().merge(server_puppetserver_version: '2.4.98') } - it { should_not contain_file('/etc/custom/puppetserver/services.d') } - it { should_not contain_file('/etc/custom/puppetserver/services.d/ca.cfg') } - it { should_not contain_file('/opt/puppetlabs/server/apps/puppetserver/config') } - it { should_not contain_file('/opt/puppetlabs/server/apps/puppetserver/config/services.d') } - end - context 'when server_puppetserver_version >= 5.1' do let(:params) { super().merge(server_puppetserver_version: '5.1.0') } it { @@ -305,35 +213,24 @@ end describe 'product.conf' do - context 'when server_puppetserver_version >= 2.7' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } - - context 'with default parameters' do - it { - should contain_file('/etc/custom/puppetserver/conf.d/product.conf') - .with_content(/^\s+check-for-updates: true/) - } - end - - context 'with server_check_for_updates => false' do - let(:params) { super().merge(server_check_for_updates: false) } - it { - should contain_file('/etc/custom/puppetserver/conf.d/product.conf') - .with_content(/^\s+check-for-updates: false/) - } - end + context 'with default parameters' do + it { + should contain_file('/etc/custom/puppetserver/conf.d/product.conf') + .with_content(/^\s+check-for-updates: true/) + } end - context 'when server_puppetserver_version < 2.7' do - let(:params) { super().merge(server_puppetserver_version: '2.6.0') } - it { should contain_file('/etc/custom/puppetserver/conf.d/product.conf').with_ensure('absent') } + context 'with server_check_for_updates => false' do + let(:params) { super().merge(server_check_for_updates: false) } + it { + should contain_file('/etc/custom/puppetserver/conf.d/product.conf') + .with_content(/^\s+check-for-updates: false/) + } end end describe 'server_metrics' do context 'when server_puppetserver_version < 5.0' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } - context 'when server_metrics => true' do let(:params) { super().merge(server_puppetserver_metrics: true) } it { @@ -402,8 +299,6 @@ describe 'server_experimental' do context 'when server_puppetserver_version < 5.0' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } - context 'when server_experimental => true' do let(:params) { super().merge(server_puppetserver_experimental: true) } it { should contain_file(auth_conf).without_content(%r{^(\ *)path: "/puppet/experimental"$}) } @@ -432,7 +327,6 @@ describe 'puppet tasks information' do context 'when server_puppetserver_version < 5.1' do - let(:params) { super().merge(server_puppetserver_version: '5.0.0') } it { should contain_file(auth_conf).without_content(%r{^(\ *)path: "/puppet/v3/tasks"$}) } end @@ -456,19 +350,13 @@ describe 'server_trusted_agents' do context 'when set' do - let(:params) do - super().merge( - server_puppetserver_version: '2.7.0', - server_puppetserver_trusted_agents: ['jenkins', 'octocatalog-diff'] - ) - end + let(:params) { super().merge(server_puppetserver_trusted_agents: ['jenkins', 'octocatalog-diff']) } it { should contain_file(auth_conf).with_content(/^ allow: \["jenkins", "octocatalog-diff", "\$1"\]$/) } end end describe 'server_jruby9k', unless: facts[:osfamily] == 'FreeBSD' do context 'when server_puppetserver_version < 5.0' do - let(:params) { super().merge(server_puppetserver_version: '2.7.0') } context 'when server_jruby9k => true' do let(:params) { super().merge(server_puppetserver_jruby9k: true) } @@ -560,9 +448,7 @@ end describe 'gem-path' do - context 'when server_puppetserver_version > 2.7 but < 5.3' do - let(:params) { super().merge(server_puppetserver_version: '5.0.0') } - + context 'when server_puppetserver_version < 5.3' do it do should contain_file(puppetserver_conf) .with_content(%r{^ gem-path: \[\$\{jruby-puppet.gem-home\}, "/opt/puppetlabs/server/data/puppetserver/vendored-jruby-gems"\]$}) @@ -621,9 +507,9 @@ end end - describe 'when server_puppetserver_version < 2.2' do - let(:params) { super().merge(server_puppetserver_version: '2.1.0') } - it { should raise_error(Puppet::Error, /puppetserver <2.2 is not supported by this module version/) } + describe 'when server_puppetserver_version < 2.7' do + let(:params) { super().merge(server_puppetserver_version: '2.6.0') } + it { should raise_error(Puppet::Error, /puppetserver <2.7 is not supported by this module version/) } end describe 'allow jetty specific server threads' do diff --git a/templates/server/puppetserver/conf.d/puppetserver.conf.erb b/templates/server/puppetserver/conf.d/puppetserver.conf.erb index 6c6a1796..c7908dfe 100644 --- a/templates/server/puppetserver/conf.d/puppetserver.conf.erb +++ b/templates/server/puppetserver/conf.d/puppetserver.conf.erb @@ -12,13 +12,11 @@ jruby-puppet: { # and also by the `puppetserver gem` command line tool. gem-home: <%= @server_jruby_gem_home %> -<%- if scope.function_versioncmp([@server_puppetserver_version, '2.7']) >= 0 -%> # This setting defines the complete "GEM_PATH" for jruby. If set, it should include # the gem-home directory as well as any other directories that gems can be loaded # from (including the vendored gems directory for gems that ship with puppetserver) gem-path: [<%= @server_gem_paths.join(', ') %>] -<%- end -%> # PLEASE NOTE: Use caution when modifying the below settings. Modifying # these settings will change the value of the corresponding Puppet settings # for Puppet Server, but not for the Puppet CLI tools. This likely will not @@ -69,11 +67,9 @@ jruby-puppet: { # specified in the Puppet Server HOCON-formatted auth.conf (if false or not # specified). use-legacy-auth-conf: <%= @server_use_legacy_auth_conf %> -<%- if scope.function_versioncmp([@server_puppetserver_version, '2.3']) >= 0 -%> # (optional) enable or disable environment class cache environment-class-cache-enabled: <%= @server_environment_class_cache_enabled %> -<%- end -%> <%- if @compile_mode %> compile-mode: <%= @compile_mode %>