diff --git a/spec/classes/puppet_agent_osfamily_aix_spec.rb b/spec/classes/puppet_agent_osfamily_aix_spec.rb index f3de5dd12..0c80e4cd3 100644 --- a/spec/classes/puppet_agent_osfamily_aix_spec.rb +++ b/spec/classes/puppet_agent_osfamily_aix_spec.rb @@ -14,7 +14,7 @@ shared_examples 'aix' do |aixver, pkg_aixver, powerver| let(:rpmname) {"puppet-agent-#{params[:package_version]}-1.aix#{pkg_aixver}.ppc.rpm"} let(:tag) { "aix-#{pkg_aixver}-power" } - let(:source) { "puppet:///pe_packages/4.0.0/#{tag}/#{rpmname}" } + let(:source) { "puppet:///pe_packages/2000.0.0/#{tag}/#{rpmname}" } let(:facts) { common_facts.merge({ architecture: "PowerPC_POWER#{powerver}", @@ -23,18 +23,8 @@ } before(:each) do - Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '4.0.0' } - Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| 'x.y.z' } - end - - if Puppet.version < "4.0.0" - it { is_expected.to contain_file('/etc/puppetlabs/puppet') } - it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf') } - - it do - is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf') - is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf') - end + Puppet::Parser::Functions.newfunction(:pe_build_version, type: :rvalue) { |_args| '2000.0.0' } + Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, type: :rvalue) { |_args| '1.10.100' } end it { is_expected.to contain_file('/opt/puppetlabs') } @@ -49,47 +39,16 @@ it { is_expected.to contain_package('puppet-agent').with({ 'source' => "/opt/puppetlabs/packages/#{rpmname}", - 'ensure' => Puppet.version < '4.0.0' ? 'present' : params[:package_version], + 'ensure' => params[:package_version], 'provider' => 'rpm', }) } - - if Puppet.version < "4.0.0" - [ - 'pe-augeas', - 'pe-mcollective-common', - 'pe-rubygem-deep-merge', - 'pe-mcollective', - 'pe-puppet-enterprise-release', - 'pe-libldap', - 'pe-libyaml', - 'pe-ruby-stomp', - 'pe-ruby-augeas', - 'pe-ruby-shadow', - 'pe-hiera', - 'pe-facter', - 'pe-puppet', - 'pe-openssl', - 'pe-ruby', - 'pe-ruby-rgen', - 'pe-virt-what', - 'pe-ruby-ldap', - ].each do |package| - it do - is_expected.to contain_package(package).with({ - 'ensure' => 'absent', - 'uninstall_options' => '--nodeps', - 'provider' => 'rpm', - }) - end - end - end end context 'with a PC1 collection' do let(:params) { { - package_version: '1.2.3', + package_version: '1.10.100', collection: 'PC1', } } diff --git a/spec/classes/puppet_agent_osfamily_darwin_spec.rb b/spec/classes/puppet_agent_osfamily_darwin_spec.rb index c30dc2edf..03108a3ea 100644 --- a/spec/classes/puppet_agent_osfamily_darwin_spec.rb +++ b/spec/classes/puppet_agent_osfamily_darwin_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' describe 'puppet_agent' do - master_package_version = '1.3.5' + master_package_version = '1.10.100' before(:each) do # Need to mock the PE functions Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - "4.0.0" + "2000.0.0" end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| @@ -13,17 +13,8 @@ end end - if Puppet.version >= "4.0.0" - package_version = '1.2.5' - let(:params) do - { - :package_version => package_version - } - end - else - # Default to PE master package version in 3.8 - package_version = master_package_version - end + package_version = '1.10.100' + let(:params) {{ package_version: package_version }} facts = { :is_pe => true, @@ -59,7 +50,7 @@ let(:facts) do facts.merge({ :is_pe => true, - :aio_agent_version => '1.0.4', + :aio_agent_version => '1.10.99', :platform_tag => tag, :macosx_productversion_major => osmajor }) @@ -75,40 +66,17 @@ it { is_expected.to contain_class('puppet_agent::install::remove_packages_osx') } it { is_expected.to contain_class("puppet_agent::osfamily::darwin") } - if Puppet.version < "4.0.0" - [ - 'pe-augeas', - 'pe-ruby-augeas', - 'pe-openssl', - 'pe-ruby', - 'pe-cfpropertylist', - 'pe-facter', - 'pe-puppet', - 'pe-mcollective', - 'pe-hiera', - 'pe-puppet-enterprise-release', - 'pe-stomp', - 'pe-libyaml', - 'pe-ruby-rgen', - 'pe-deep-merge', - 'pe-ruby-shadow', - ].each do |package| - it { is_expected.to contain_exec("forget #{package}").with_command("/usr/sbin/pkgutil --forget com.puppetlabs.#{package}") } - it { is_expected.to contain_exec("forget #{package}").with_require('File[/opt/puppet]') } - end - else - context 'aio_agent_version is out of date' do - let(:facts) do - facts.merge({ - :aio_agent_version => '1.0.0' - }) - end - - it { is_expected.not_to contain_exec('forget puppet-agent') } + context 'aio_agent_version is out of date' do + let(:facts) do + facts.merge({ + :aio_agent_version => '0.0.1' + }) end it { is_expected.not_to contain_exec('forget puppet-agent') } end + + it { is_expected.not_to contain_exec('forget puppet-agent') } end end end diff --git a/spec/classes/puppet_agent_osfamily_debian_spec.rb b/spec/classes/puppet_agent_osfamily_debian_spec.rb index 998690f28..0f702161f 100644 --- a/spec/classes/puppet_agent_osfamily_debian_spec.rb +++ b/spec/classes/puppet_agent_osfamily_debian_spec.rb @@ -19,7 +19,7 @@ } # All FOSS and all Puppet 4+ upgrades require the package_version - package_version = '1.2.5' + package_version = '1.10.100' let(:params) { { :package_version => package_version @@ -35,7 +35,7 @@ # Need to mock the PE functions Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - '4.0.0' + '2000.0.0' end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| @@ -179,7 +179,7 @@ }) } it { is_expected.to contain_apt__source('pc_repo').with({ - 'location' => 'https://master.example.vm:8140/packages/4.0.0/debian-7-x86_64', + 'location' => 'https://master.example.vm:8140/packages/2000.0.0/debian-7-x86_64', 'repos' => 'PC1', 'key' => { 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', diff --git a/spec/classes/puppet_agent_osfamily_redhat_spec.rb b/spec/classes/puppet_agent_osfamily_redhat_spec.rb index e21c3a70d..6ea6b4e0e 100644 --- a/spec/classes/puppet_agent_osfamily_redhat_spec.rb +++ b/spec/classes/puppet_agent_osfamily_redhat_spec.rb @@ -126,7 +126,7 @@ # Need to mock the PE functions Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - '4.0.0' + '2000.0.0' end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| @@ -154,7 +154,7 @@ it { is_expected.to contain_yumrepo('puppetlabs-pepackages').with_ensure('absent') } it { is_expected.to contain_yumrepo('pc_repo').with({ - 'baseurl' => "https://master.example.vm:8140/packages/4.0.0/#{repodir}", + 'baseurl' => "https://master.example.vm:8140/packages/2000.0.0/#{repodir}", 'enabled' => 'true', 'gpgcheck' => '1', 'gpgkey' => "file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppetlabs\n file:///etc/pki/rpm-gpg/RPM-GPG-KEY-puppet", diff --git a/spec/classes/puppet_agent_osfamily_solaris_spec.rb b/spec/classes/puppet_agent_osfamily_solaris_spec.rb index 497e2c4c5..bcb2110a3 100644 --- a/spec/classes/puppet_agent_osfamily_solaris_spec.rb +++ b/spec/classes/puppet_agent_osfamily_solaris_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'puppet_agent' do - package_version = '1.2.5.90.g93a35da' + package_version = '1.10.100.90.g93a35da' facts = { :osfamily => 'Solaris', @@ -17,15 +17,9 @@ # Strips out strings in the version string on Solaris 11, # because pkg doesn't accept strings in version numbers. This # is how developer builds are labelled. - sol11_package_version = '1.2.5.90.9335' + sol11_package_version = '1.10.100.90.9335' pe_version = '2000.0.0' - if Puppet.version >= "4.0.0" - let(:params) do - { - :package_version => package_version - } - end - end + let(:params) {{ package_version: package_version }} describe 'unsupported environment' do context 'when not PE' do @@ -116,44 +110,9 @@ end end - if Puppet.version < "4.0.0" - [ - 'pe-augeas', - 'pe-deep-merge', - 'pe-facter', - 'pe-hiera', - 'pe-libldap', - 'pe-libyaml', - 'pe-mcollective', - 'pe-mcollective-common', - 'pe-openssl', - 'pe-puppet', - 'pe-puppet-enterprise-release', - 'pe-ruby', - 'pe-ruby-augeas', - 'pe-ruby-ldap', - 'pe-ruby-rgen', - 'pe-ruby-shadow', - 'pe-stomp', - 'pe-virt-what', - ].each do |package| - it do - is_expected.to contain_package(package).with_ensure('absent') - end - end - - it do - is_expected.to contain_exec('puppet_agent backup /etc/puppetlabs/').with({ - 'command' => 'cp -r /etc/puppetlabs/ /tmp/puppet_agent/', - }) - - is_expected.to contain_package('puppet-agent').with_ensure('present') - end - else - it do - is_expected.not_to contain_transition("remove puppet-agent") - is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) - end + it do + is_expected.not_to contain_transition("remove puppet-agent") + is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) end end @@ -211,44 +170,9 @@ end - if Puppet.version < "4.0.0" - [ - 'pe-augeas', - 'pe-deep-merge', - 'pe-facter', - 'pe-hiera', - 'pe-libldap', - 'pe-libyaml', - 'pe-mcollective', - 'pe-mcollective-common', - 'pe-openssl', - 'pe-puppet', - 'pe-puppet-enterprise-release', - 'pe-ruby', - 'pe-ruby-augeas', - 'pe-ruby-ldap', - 'pe-ruby-rgen', - 'pe-ruby-shadow', - 'pe-stomp', - 'pe-virt-what', - ].each do |package| - it do - is_expected.to contain_package(package).with_ensure('absent') - end - end - - it do - is_expected.to contain_exec('puppet_agent backup /etc/puppetlabs/').with({ - 'command' => 'cp -r /etc/puppetlabs/ /tmp/puppet_agent/', - }) - - is_expected.to contain_package('puppet-agent').with_ensure('present') - end - else - it do - is_expected.not_to contain_transition("remove puppet-agent") - is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) - end + it do + is_expected.not_to contain_transition("remove puppet-agent") + is_expected.to contain_package('puppet-agent').with_ensure(sol11_package_version) end end @@ -279,33 +203,26 @@ it { is_expected.to contain_class("puppet_agent::osfamily::solaris") } - if Puppet.version < "4.0.0" - it do - is_expected.to contain_file('/tmp/solaris_install.sh') - is_expected.to contain_exec('solaris_install script') - end - else - context 'with older aio_agent_version' do - let(:facts) do - facts.merge({ - :is_pe => true, - :platform_tag => "solaris-10-i386", - :operatingsystemmajrelease => '10', - :aio_agent_version => '1.0.0', - }) - end - - it do - is_expected.to contain_file('/tmp/solaris_install.sh').with_ensure('file') - is_expected.to contain_exec('solaris_install script').with_command('/usr/bin/ctrun -l none /tmp/solaris_install.sh 42 2>&1 > /tmp/solaris_install.log &') - end + context 'with older aio_agent_version' do + let(:facts) do + facts.merge({ + :is_pe => true, + :platform_tag => "solaris-10-i386", + :operatingsystemmajrelease => '10', + :aio_agent_version => '1.0.0', + }) end it do - is_expected.not_to contain_file('/tmp/solaris_install.sh') - is_expected.not_to contain_exec('solaris_install script') + is_expected.to contain_file('/tmp/solaris_install.sh').with_ensure('file') + is_expected.to contain_exec('solaris_install script').with_command('/usr/bin/ctrun -l none /tmp/solaris_install.sh 42 2>&1 > /tmp/solaris_install.log &') end end + + it do + is_expected.not_to contain_file('/tmp/solaris_install.sh') + is_expected.not_to contain_exec('solaris_install script') + end end context "when Solaris 10 sparc sun4u" do @@ -347,33 +264,26 @@ it { is_expected.to contain_class("puppet_agent::osfamily::solaris") } - if Puppet.version < "4.0.0" - it do - is_expected.to contain_file('/tmp/solaris_install.sh') - is_expected.to contain_exec('solaris_install script') - end - else - context 'with older aio_agent_version' do - let(:facts) do - facts.merge({ - :is_pe => true, - :platform_tag => "solaris-10-sparc", - :operatingsystemmajrelease => '10', - :aio_agent_version => '1.0.0', - }) - end - - it do - is_expected.to contain_file('/tmp/solaris_install.sh').with_ensure('file') - is_expected.to contain_exec('solaris_install script').with_command('/usr/bin/ctrun -l none /tmp/solaris_install.sh 42 2>&1 > /tmp/solaris_install.log &') - end + context 'with older aio_agent_version' do + let(:facts) do + facts.merge({ + :is_pe => true, + :platform_tag => "solaris-10-sparc", + :operatingsystemmajrelease => '10', + :aio_agent_version => '1.0.0', + }) end it do - is_expected.not_to contain_file('/tmp/solaris_install.sh') - is_expected.not_to contain_exec('solaris_install script') + is_expected.to contain_file('/tmp/solaris_install.sh').with_ensure('file') + is_expected.to contain_exec('solaris_install script').with_command('/usr/bin/ctrun -l none /tmp/solaris_install.sh 42 2>&1 > /tmp/solaris_install.log &') end end + + it do + is_expected.not_to contain_file('/tmp/solaris_install.sh') + is_expected.not_to contain_exec('solaris_install script') + end end end end diff --git a/spec/classes/puppet_agent_osfamily_suse_spec.rb b/spec/classes/puppet_agent_osfamily_suse_spec.rb index 146cbdfc7..99866f90a 100644 --- a/spec/classes/puppet_agent_osfamily_suse_spec.rb +++ b/spec/classes/puppet_agent_osfamily_suse_spec.rb @@ -1,15 +1,15 @@ require 'spec_helper' describe 'puppet_agent' do - package_version = '1.2.5' + package_version = '1.10.100' before(:each) do # Need to mock the PE functions Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - "4.0.0" + "2000.0.0" end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| - '1.2.5' + package_version end end @@ -65,55 +65,16 @@ it { is_expected.to contain_file('/opt/puppetlabs') } it { is_expected.to contain_file('/opt/puppetlabs/packages') } it do - is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.sles10.x86_64.rpm').with_ensure('present') - is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.sles10.x86_64.rpm').with_source('puppet:///pe_packages/4.0.0/sles-10-x86_64/puppet-agent-1.2.5-1.sles10.x86_64.rpm') + is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles10.x86_64.rpm').with_ensure('present') + is_expected.to contain_file('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles10.x86_64.rpm').with_source('puppet:///pe_packages/2000.0.0/sles-10-x86_64/puppet-agent-1.10.100-1.sles10.x86_64.rpm') end it { is_expected.to contain_class("puppet_agent::osfamily::suse") } - - if Puppet.version < "4.0.0" - it { is_expected.to contain_class("puppet_agent::prepare::package") } - - it do - is_expected.to contain_exec('replace puppet.conf removed by package removal').with_command('cp /etc/puppetlabs/puppet/puppet.conf.rpmsave /etc/puppetlabs/puppet/puppet.conf') - is_expected.to contain_exec('replace puppet.conf removed by package removal').with_creates('/etc/puppetlabs/puppet/puppet.conf') - end - - it { is_expected.to contain_class("puppet_agent::install::remove_packages") } - [ - 'pe-augeas', - 'pe-mcollective-common', - 'pe-rubygem-deep-merge', - 'pe-mcollective', - 'pe-puppet-enterprise-release', - 'pe-libldap', - 'pe-libyaml', - 'pe-ruby-stomp', - 'pe-ruby-augeas', - 'pe-ruby-shadow', - 'pe-hiera', - 'pe-facter', - 'pe-puppet', - 'pe-openssl', - 'pe-ruby', - 'pe-ruby-rgen', - 'pe-virt-what', - 'pe-ruby-ldap', - ].each do |package| - it do - is_expected.to contain_package(package).with_ensure('absent') - is_expected.to contain_package(package).with_uninstall_options('--nodeps') - is_expected.to contain_package(package).with_provider('rpm') - end - end - it { is_expected.to contain_package('puppet-agent').with_ensure('present') } - else - it { is_expected.to contain_package('puppet-agent').with_ensure('1.2.5') } - end + it { is_expected.to contain_package('puppet-agent').with_ensure('1.10.100') } it do is_expected.to contain_package('puppet-agent').with_provider('rpm') - is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.2.5-1.sles10.x86_64.rpm') + is_expected.to contain_package('puppet-agent').with_source('/opt/puppetlabs/packages/puppet-agent-1.10.100-1.sles10.x86_64.rpm') end end @@ -188,7 +149,7 @@ 'name' => 'pc_repo', 'enabled' => '1', 'autorefresh' => '0', - 'baseurl' => "https://master.example.vm:8140/packages/4.0.0/sles-#{os_version}-x86_64?ssl_verify=no", + 'baseurl' => "https://master.example.vm:8140/packages/2000.0.0/sles-#{os_version}-x86_64?ssl_verify=no", 'type' => 'rpm-md', }.each do |setting, value| it { is_expected.to contain_ini_setting("zypper pc_repo #{setting}").with({ diff --git a/spec/classes/puppet_agent_osfamily_windows_spec.rb b/spec/classes/puppet_agent_osfamily_windows_spec.rb index c02991a12..922659753 100644 --- a/spec/classes/puppet_agent_osfamily_windows_spec.rb +++ b/spec/classes/puppet_agent_osfamily_windows_spec.rb @@ -1,14 +1,10 @@ require 'spec_helper' describe 'puppet_agent' do - package_version = '1.2.5' + package_version = '1.10.100' pe_version = '2000.0.0' - if Puppet.version >= '4.0.0' - let(:params) {{ - :package_version => package_version - }} - end + let(:params) {{ package_version: package_version }} before(:each) do # Need to mock the PE functions @@ -27,6 +23,7 @@ let(:facts) {{ :is_pe => true, :osfamily => 'windows', + :operatingsystem => 'windows', :architecture => arch, :servername => 'master.example.vm', :clientcert => 'foo.example.vm', diff --git a/spec/classes/puppet_agent_prepare_spec.rb b/spec/classes/puppet_agent_prepare_spec.rb index 3c6067ef6..f1a90f6b7 100644 --- a/spec/classes/puppet_agent_prepare_spec.rb +++ b/spec/classes/puppet_agent_prepare_spec.rb @@ -43,12 +43,6 @@ 'hostcrl' => { 'path_exists' => false } }}) } - # We don't perform SSL migration post-4 upgrade - if Puppet.version < "4.0.0" - ['certificate_requests', 'certs', 'private', 'private_keys', 'public_keys', 'crl.pem'].each do |path| - it { is_expected.to_not contain_file("/etc/puppetlabs/puppet/ssl/#{path}") } - end - end end [ @@ -71,89 +65,10 @@ :mco_client_settings => mco_settings, }) } - - # We don't perform MCO migration post-4 upgrade - if Puppet.version < "4.0.0" - it { is_expected.to contain_file('/etc/puppetlabs/mcollective').with_ensure('directory') } - - mco_config.each do |node, cfg| - if cfg - it { is_expected.to contain_file(MCO_CFG[node]).with({ - 'ensure' => 'file', - 'source' => cfg, - }) } - - if mco_settings && mco_settings['libdir'] && !mco_settings['libdir'].include?(MCO_LIBDIR) - it { is_expected.to contain_ini_setting("#{node}/libdir").with({ - 'section' => '', - 'setting' => 'libdir', - 'path' => MCO_CFG[node], - 'value' => "#{MCO_LIBDIR}:#{mco_settings['libdir']}", - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_ini_setting("#{node}/libdir") } - end - - if mco_settings && mco_settings['plugin.yaml'] && !mco_settings['plugin.yaml'].include?(MCO_PLUGIN_YAML) - it { is_expected.to contain_ini_setting("#{node}/plugin.yaml").with({ - 'section' => '', - 'setting' => 'plugin.yaml', - 'path' => MCO_CFG[node], - 'value' => "#{mco_settings['plugin.yaml']}:#{MCO_PLUGIN_YAML}", - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_ini_setting("#{node}/plugin.yaml") } - end - - it { is_expected.to contain_ini_setting("#{node}/logfile").with({ - 'section' => '', - 'setting' => 'logfile', - 'path' => MCO_CFG[node], - 'value' => MCO_LOGFILE, - }).that_requires("File[#{MCO_CFG[node]}]") } - else - it { is_expected.to_not contain_file(MCO_CFG[node]) } - end - end - end end end end - # We don't perform file migration post-4 upgrade - if Puppet.version < "4.0.0" - ['/etc/puppetlabs', '/etc/puppetlabs/puppet'].each do |dir| - it { is_expected.to contain_file(dir).with_ensure('directory') } - end - - it { is_expected.to contain_file('/etc/puppetlabs/puppet/puppet.conf').with({ - 'ensure' => 'file', - 'source' => '/dev/null/puppet.conf', - }) } - - it { is_expected.to contain_file('/etc/puppetlabs/puppet/ssl').with({ - 'ensure' => 'directory', - 'source' => '/dev/null/ssl', - 'backup' => 'false', - 'recurse' => 'false', - }) } - - ['certificate_requests', 'certs', 'private', 'private_keys', 'public_keys'].each do |dir| - it { is_expected.to contain_file("/etc/puppetlabs/puppet/ssl/#{dir}").with({ - 'ensure' => 'directory', - 'source' => "/dev/null/ssl/#{dir}", - 'backup' => 'false', - 'recurse' => 'true', - }) } - end - - it { is_expected.to contain_file('/etc/puppetlabs/puppet/ssl/crl.pem').with({ - 'ensure' => 'file', - 'source' => '/dev/null/ssl/crl.pem', - 'backup' => 'false', - }) } - end - ['', 'agent', 'main', 'master'].each do |section| ['allow_variables_with_dashes', 'async_storeconfigs', @@ -216,35 +131,16 @@ 'libdir', 'confdir', 'classfile'].each do |setting| - if Puppet.version >= '4.0.0' - it { is_expected.not_to contain_ini_setting("#{section}/#{setting}") } - else - it { is_expected.to contain_ini_setting("#{section}/#{setting}").with_ensure('absent') } - end + it { is_expected.not_to contain_ini_setting("#{section}/#{setting}") } end - if Puppet.version < '4.0.0' - it { is_expected.to contain_ini_setting("#{section}/pluginsync").with_ensure('absent') } - else - context 'upgrading to puppet-agent < 1.4.0' do - let(:params) {{ :package_version => '1.3.0' }} - - it { is_expected.not_to contain_ini_setting("#{section}/pluginsync") } - end - - context 'upgrading to puppet-agent >= 1.4.0' do - let(:params) {{ :package_version => '1.4.0' }} - - it { is_expected.to contain_ini_setting("#{section}/pluginsync").with_ensure('absent') } - end - end - end + let(:params) {{ package_version: '1.10.100' }} - if Puppet.version >= "4.0.0" - it { is_expected.not_to contain_class("puppet_agent::prepare::ssl") } - it { is_expected.not_to contain_class("puppet_agent::prepare::mco_client_config") } + it { is_expected.to contain_ini_setting("#{section}/pluginsync").with_ensure('absent') } end + it { is_expected.not_to contain_class("puppet_agent::prepare::ssl") } + it { is_expected.not_to contain_class("puppet_agent::prepare::mco_client_config") } it { is_expected.to contain_class("puppet_agent::prepare::puppet_config") } it { is_expected.to contain_class("puppet_agent::osfamily::#{facts[:osfamily]}") } end diff --git a/spec/classes/puppet_agent_prepare_stringify_facts_spec.rb b/spec/classes/puppet_agent_prepare_stringify_facts_spec.rb deleted file mode 100644 index 3178a1517..000000000 --- a/spec/classes/puppet_agent_prepare_stringify_facts_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe 'puppet_agent::prepare::stringify_facts' do - context 'supported operating system families' do - %w[Debian RedHat SuSE].each do |osfamily| - case osfamily - when 'SuSE' - os = 'SLES' - osmajor = '10' - else - os = 'foo' - osmajor = '42' - end - - facts = { - operatingsystem: os, - operatingsystemmajrelease: osmajor, - architecture: 'bar', - osfamily: osfamily, - lsbdistid: osfamily, - lsbdistcodename: 'baz', - mco_server_config: nil, - mco_client_config: nil - } - - context "on #{osfamily}" do - if Puppet.version < '4.0.0' - context 'on Puppet 3 or lower' do - it { - is_expected.to contain_ini_setting('puppet stringify_facts').with( - ensure: 'present', - value: false - ) - } - end - else - context 'on Puppet 4 or higher' do - it { - is_expected.to_not contain_ini_setting('puppet stringify_facts').with( - ensure: 'present', - value: false - ) - } - end - end - end - end - end -end diff --git a/spec/classes/puppet_agent_spec.rb b/spec/classes/puppet_agent_spec.rb index 7d8aed5c9..009fab904 100644 --- a/spec/classes/puppet_agent_spec.rb +++ b/spec/classes/puppet_agent_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe 'puppet_agent' do - package_version = '1.2.5' + package_version = '6.5.4' global_params = { :package_version => package_version } @@ -23,7 +23,7 @@ def global_facts(facts, os) :mco_confdir => 'C:\\ProgramData\\Puppetlabs\\mcollective\\etc', :env_temp_variable => 'C:/tmp', :puppet_agent_pid => 42, - :puppet_config => Puppet.version < "4.0.0" ? "file:///C:\\\\puppet.conf" : "C:\\puppet.conf", + :puppet_config => "C:\\puppet.conf", } else {} @@ -64,23 +64,19 @@ def global_facts(facts, os) end before(:each) do - Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) {|args| '4.0.0'} - Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) {|args| '1.2.5'} - Puppet::Parser::Functions.newfunction(:pe_compiling_server_version, :type => :rvalue) {|args| '2.2.0'} + Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) {|args| '2000.0.0'} + Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) {|args| '1.10.100'} + Puppet::Parser::Functions.newfunction(:pe_compiling_server_version, :type => :rvalue) {|args| '2.20.200'} end context 'package_version is initialized automatically' do - if Puppet.version < '4.0.0' - it { is_expected.to contain_class('puppet_agent').with_package_version('1.2.5') } - else - it { is_expected.to contain_class('puppet_agent').with_package_version(nil) } - end + it { is_expected.to contain_class('puppet_agent').with_package_version(nil) } end - context 'On a PE infrastructure node puppet_agent does nothing', :if => Puppet.version >= '4.0.0' do + context 'On a PE infrastructure node puppet_agent does nothing' do # The puppet version conditional is only required if the module supports Puppet 3.x before(:each) do - facts['pe_server_version'] = '2016.2.2' + facts['pe_server_version'] = '2000.0.0' end it { is_expected.to_not contain_class('puppet_agent::prepare') } it { is_expected.to_not contain_class('puppet_agent::install') } @@ -108,11 +104,11 @@ def global_facts(facts, os) # Need to mock the PE functions Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - '4.0.0' + '2000.0.0' end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| - '1.2.5' + '1.10.100' end end end @@ -180,8 +176,8 @@ def global_facts(facts, os) # Windows platform does not use Service resources unless facts[:osfamily] == 'windows' if params[:service_names].nil? && - !(facts[:osfamily] == 'Solaris' && facts[:operatingsystemmajrelease] == '11') && - (Puppet.version < "4.0.0" || os !~ /sles/) + !(facts[:osfamily] == 'Solaris' && facts[:operatingsystemmajrelease] == '11') && + os !~ /sles/ it { is_expected.to contain_service('puppet') } it { is_expected.to contain_service('mcollective') } else @@ -209,26 +205,4 @@ def global_facts(facts, os) it { is_expected.to raise_error(Puppet::Error, /Nexenta not supported/) } end end - - context 'stringify_facts is set to true' do - describe 'when puppet_stringify_facts evaluates as true ' do - # Mock a supported agent but with puppet_stringify_facts set to true - # check for both boolean true and string true - [ true, 'true' ].each do |truthiness| - let(:facts) {{ - :osfamily => 'RedHat', - :operatingsystem => 'Fedora', - :puppet_ssldir => '/dev/null/ssl', - :puppet_config => '/dev/null/puppet.conf', - :architecture => 'i386', - :puppet_stringify_facts => truthiness, - }} - let(:params) { global_params } - - if Puppet.version < '4.0.0' - it { is_expected.to raise_error(Puppet::Error, /requires stringify_facts to be disabled/) } - end - end - end - end end diff --git a/spec/classes/puppet_agent_windows_install_spec.rb b/spec/classes/puppet_agent_windows_install_spec.rb index d1c1c9c17..777e6800a 100644 --- a/spec/classes/puppet_agent_windows_install_spec.rb +++ b/spec/classes/puppet_agent_windows_install_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' -RSpec.describe 'puppet_agent' do - package_version = '1.2.1.1' +RSpec.describe 'puppet_agent', tag: 'win' do + package_version = '1.10.100.1' global_params = { :package_version => package_version } - {'5.1' => {:expect_arch => 'x86', :appdata => 'C:\Document and Settings\All Users\Application Data'}, - '6.1' => {:expect_arch => 'x64', :appdata => 'C:\ProgramData'}}.each do |kernelmajversion, values| + {'5.1' => {:expect_arch => 'x86', :appdata => 'C:\Documents and Settings\All Users\Application Data'}, + '10.0' => {:expect_arch => 'x64', :appdata => 'C:\ProgramData'}}.each do |kernelmajversion, values| context "Windows Kernelmajversion #{kernelmajversion}" do facts = { :architecture => 'x64', :env_temp_variable => 'C:/tmp', :kernelmajversion => kernelmajversion, :osfamily => 'windows', - :puppetversion => '3.8.0', + :puppetversion => '4.10.100', :puppet_confdir => "#{values[:appdata]}\\Puppetlabs\\puppet\\etc", :mco_confdir => "#{values[:appdata]}\\Puppetlabs\\mcollective\\etc", :puppet_agent_pid => 42, @@ -25,16 +25,11 @@ let(:facts) { facts } let(:params) { global_params } - context 'without aio_agent_version (FOSS)' do - it { is_expected.to contain_class('puppet_agent::windows::install') } - end - context 'is_pe' do before(:each) do # Need to mock the PE functions - Puppet::Parser::Functions.newfunction(:pe_build_version, :type => :rvalue) do |args| - '4.0.0' + '4.10.100' end Puppet::Parser::Functions.newfunction(:pe_compiling_server_aio_build, :type => :rvalue) do |args| @@ -44,55 +39,41 @@ let(:facts) { facts.merge({:is_pe => true}) } - if Puppet.version < '4.0.0' - context 'with aio_agent_version unset' do - let(:facts) { facts.merge({:is_pe => true}) } + context 'with up to date aio_agent_version matching server' do + let(:facts) { facts.merge({ + :is_pe => true, + :aio_agent_version => package_version + })} - it { is_expected.to contain_class('puppet_agent::windows::install') } - it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content( - %r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"#{values[:appdata]}\\Puppetlabs\\packages\\puppet-agent-#{values[:expect_arch]}.msi\"")}]) - } - it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } - end + it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') } + it { is_expected.not_to contain_exec('fix inheritable SYSTEM perms') } end - if Puppet.version >= '4.0.0' - context 'with up to date aio_agent_version matching server' do - let(:facts) { facts.merge({ - :is_pe => true, - :aio_agent_version => package_version - })} + context 'with equal package_version containing git sha' do + let(:facts) { facts.merge({ + :is_pe => true, + :aio_agent_version => package_version + })} - it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') } - it { is_expected.not_to contain_exec('fix inheritable SYSTEM perms') } - end - - context 'with equal package_version containing git sha' do - let(:facts) { facts.merge({ - :is_pe => true, - :aio_agent_version => package_version - })} + let(:params) { + global_params.merge(:package_version => "#{package_version}.g886c5ab") + } - let(:params) { - global_params.merge(:package_version => "#{package_version}.g886c5ab") - } + it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') } + it { is_expected.not_to contain_exec('install_puppet.bat') } + end - it { is_expected.not_to contain_file('c:\tmp\install_puppet.bat') } - it { is_expected.not_to contain_exec('install_puppet.bat') } - end + context 'with out of date aio_agent_version' do + let(:facts) { facts.merge({ + :is_pe => true, + :aio_agent_version => '1.10.0' + })} - context 'with out of date aio_agent_version' do - let(:facts) { facts.merge({ - :is_pe => true, - :aio_agent_version => '1.2.0' - })} - - it { is_expected.to contain_class('puppet_agent::windows::install') } - it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content( - %r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"#{values[:appdata]}\\Puppetlabs\\packages\\puppet-agent-#{values[:expect_arch]}.msi\"")}]) - } - it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } - end + it { is_expected.to contain_class('puppet_agent::windows::install') } + it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content( + %r[#{Regexp.escape("msiexec.exe /qn /norestart /i \"#{values[:appdata]}\\Puppetlabs\\packages\\puppet-agent-#{values[:expect_arch]}.msi\"")}]) + } + it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end end @@ -130,6 +111,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'C:/tmp/puppet-agent-x64.msi' do let(:params) { global_params.merge( {:source => 'C:/tmp/puppet-agent-x64.msi',}) @@ -141,6 +123,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'C:\Temp/ Folder\puppet-agent-x64.msi' do let(:params) { global_params.merge( {:source => 'C:\Temp/ Folder\puppet-agent-x64.msi',}) @@ -152,6 +135,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'C:/Temp/ Folder/puppet-agent-x64.msi' do let(:params) { global_params.merge( {:source => 'C:/Temp/ Folder/puppet-agent-x64.msi',}) @@ -163,6 +147,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe '\\\\garded\c$\puppet-agent-x64.msi' do let(:params) { global_params.merge( {:source => "\\\\garded\\c$\\puppet-agent-x64.msi",}) @@ -174,6 +159,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'default source' do it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content( @@ -190,6 +176,7 @@ } it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'puppet:///puppet_agent/puppet-agent-1.1.0-x86.msi' do let(:params) { global_params.merge( {:source => 'puppet:///puppet_agent/puppet-agent-1.1.0-x86.msi'}) @@ -203,6 +190,7 @@ it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end end + context 'arch =>' do describe 'specify x86' do let(:params) { global_params.merge( @@ -218,45 +206,53 @@ describe 'try x64 on x86 system' do let(:facts) { { :osfamily => 'windows', - :puppetversion => '3.8.0', + :puppetversion => '4.10.100', :tmpdir => 'C:\tmp', :architecture => 'x86', :system32 => 'C:\windows\sysnative', :puppet_confdir => "#{values[:appdata]}\\Puppetlabs\\puppet\\etc", :mco_confdir => "#{values[:appdata]}\\Puppetlabs\\mcollective\\etc", } } + let(:params) { global_params.merge( {:arch => 'x64'}) } + it { expect { catalogue }.to raise_error(Puppet::Error, /Unable to install x64 on a x86 system/) } end end + context 'msi_move_locked_files =>' do describe 'default' do it { is_expected.to contain_file('C:\tmp\install_puppet.bat').without_content(/Move puppetres\.dll/) - } + } end + describe 'specify false' do let(:params) { global_params.merge( {:msi_move_locked_files => false,}) } + it { is_expected.to contain_file('C:\tmp\install_puppet.bat').without_content(/Move puppetres\.dll/) - } + } end + describe 'specify true' do let(:params) { global_params.merge( {:msi_move_locked_files => true,}) } + it { is_expected.to contain_file('C:\tmp\install_puppet.bat').with_content(/Move puppetres\.dll/) - } + } end end end + context 'rubyplatform' do facts = { :architecture => 'x64', @@ -270,26 +266,30 @@ :system32 => 'C:\windows\sysnative', :tmpdir => 'C:\tmp', } + describe 'i386-ming32' do let(:facts) { facts.merge({:rubyplatform => 'i386-ming32'}) } let(:params) { global_params } + it { is_expected.to contain_exec('install_puppet.bat').with { { 'command' => 'C:\windows\sysnative\cmd.exe /c start /b C:\windows\system32\cmd.exe /c "C:\tmp\install_puppet.bat" 42', } } - } + it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end + describe 'x86' do let(:facts) { facts.merge({:rubyplatform => 'x86_64'}) } let(:params) { global_params } + it { is_expected.to contain_exec('install_puppet.bat').with { { 'command' => 'C:\windows\sysnative\cmd.exe /c start /b C:\windows\sysnative\cmd.exe /c "C:\tmp\install_puppet.bat" 42', } } - } + it { is_expected.to contain_exec('fix inheritable SYSTEM perms') } end end diff --git a/spec/unit/facter/settings_spec.rb b/spec/unit/facter/settings_spec.rb index 66da98603..cd23a9c4f 100644 --- a/spec/unit/facter/settings_spec.rb +++ b/spec/unit/facter/settings_spec.rb @@ -18,7 +18,7 @@ end end -describe "puppet_stringify_facts fact for Puppet 4.x+", :unless => /3\./ =~ Puppet.version do +describe "puppet_stringify_facts fact" do subject { Facter.fact("puppet_stringify_facts".to_sym).value } after(:each) { Facter.clear } @@ -27,39 +27,6 @@ end end -describe "puppet_stringify_facts fact for Puppet 3.x", :if => /3\./ =~ Puppet.version do - subject { Facter.fact("puppet_stringify_facts".to_sym).value } - after(:each) { Facter.clear } - - describe 'when not set in Puppet' do - before(:each) { - mocked_settings = Puppet::Settings.new - Puppet.stubs(:settings).returns(mocked_settings) - } - it { is_expected.to eq(false) } - end - - describe 'when set false in Puppet' do - before(:each) { - mocked_settings = Puppet::Settings.new - mocked_settings.define_settings :main, :stringify_facts => { :default => false, :type => :boolean, :desc => 'mocked stringify_facts setting' } - Puppet.stubs(:settings).returns(mocked_settings) - } - - it { is_expected.to eq(false) } - end - - describe 'when set true in Puppet' do - before(:each) { - mocked_settings = Puppet::Settings.new - mocked_settings.define_settings :main, :stringify_facts => { :default => true, :type => :boolean, :desc => 'mocked stringify_facts setting' } - Puppet.stubs(:settings).returns(mocked_settings) - } - - it { is_expected.to eq(true) } - end -end - describe "puppet_sslpaths fact" do subject { Facter.fact("puppet_sslpaths".to_sym).value } after(:each) { Facter.clear }