From: TP Honey Date: Thu, 21 Jun 2018 12:25:50 +0000 (+0100) Subject: Merge pull request #752 from antaflos/apt_auth_conf_support X-Git-Tag: 5.0.0~5 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=630580d1ce3c609865e31598198e7c55dda9a6ef;hp=d4e1a346103ed0eb5d60e311da79f2ed315b716b;p=puppet-modules%2Fpuppetlabs-apt.git Merge pull request #752 from antaflos/apt_auth_conf_support Support managing login configurations in /etc/apt/auth.conf --- diff --git a/.gitignore b/.gitignore index d17e987..49bc2a4 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,11 @@ /Gemfile.lock /junit/ /log/ -/log/ /pkg/ /spec/fixtures/manifests/ /spec/fixtures/modules/ /tmp/ /vendor/ /convert_report.txt - +/update_report.txt +.DS_Store diff --git a/.pdkignore b/.pdkignore new file mode 100644 index 0000000..49bc2a4 --- /dev/null +++ b/.pdkignore @@ -0,0 +1,23 @@ +.*.sw[op] +.metadata +.yardoc +.yardwarns +*.iml +/.bundle/ +/.idea/ +/.vagrant/ +/coverage/ +/bin/ +/doc/ +/Gemfile.local +/Gemfile.lock +/junit/ +/log/ +/pkg/ +/spec/fixtures/manifests/ +/spec/fixtures/modules/ +/tmp/ +/vendor/ +/convert_report.txt +/update_report.txt +.DS_Store diff --git a/.rubocop.yml b/.rubocop.yml index a658984..7ed6225 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,11 +8,14 @@ AllCops: Exclude: - bin/* - ".vendor/**/*" - - Gemfile - - Rakefile + - "**/Gemfile" + - "**/Rakefile" - pkg/**/* - spec/fixtures/**/* - vendor/**/* + - "**/Puppetfile" + - "**/Vagrantfile" + - "**/Guardfile" Metrics/LineLength: Description: People have wide screens, use them. Max: 200 @@ -63,6 +66,13 @@ Style/TrailingCommaInLiteral: Style/SymbolArray: Description: Using percent style obscures symbolic intent of array's contents. EnforcedStyle: brackets +RSpec/MessageSpies: + EnforcedStyle: receive +Style/Documentation: + Exclude: + - lib/puppet/parser/functions/**/* +Style/WordArray: + EnforcedStyle: brackets Style/CollectionMethods: Enabled: true Style/MethodCalledOnDoEndBlock: diff --git a/.sync.yml b/.sync.yml index 9a44c1c..7bfce72 100644 --- a/.sync.yml +++ b/.sync.yml @@ -33,3 +33,6 @@ Gemfile: appveyor.yml: delete: true + +.gitlab-ci.yml: + unmanaged: true diff --git a/.travis.yml b/.travis.yml index bc1d2dc..256d5c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,6 @@ before_install: - bundle -v - rm -f Gemfile.lock - gem update --system - - gem update bundler - gem --version - bundle -v script: @@ -16,14 +15,15 @@ bundler_args: --without system_tests rvm: - 2.4.1 env: - - PUPPET_GEM_VERSION="~> 5.0" CHECK=spec + global: + - BEAKER_PUPPET_COLLECTION=puppet5 PUPPET_GEM_VERSION="~> 5.0" matrix: fast_finish: true include: - bundler_args: dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8 + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/debian-8 rvm: 2.4.1 script: bundle exec rake beaker services: docker @@ -31,23 +31,17 @@ matrix: - bundler_args: dist: trusty - env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet5 BEAKER_set=docker/ubuntu-14.04 rvm: 2.4.1 script: bundle exec rake beaker services: docker sudo: required - - env: CHECK=rubocop + env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - env: CHECK="syntax lint" + env: CHECK=parallel_spec - - env: CHECK=metadata_lint - - - env: CHECK=release_checks - - - env: CHECK=spec - - - env: PUPPET_GEM_VERSION="~> 4.0" CHECK=spec + env: PUPPET_GEM_VERSION="~> 4.0" CHECK=parallel_spec rvm: 2.1.9 branches: only: diff --git a/.yardopts b/.yardopts new file mode 100644 index 0000000..29c933b --- /dev/null +++ b/.yardopts @@ -0,0 +1 @@ +--markup markdown diff --git a/Gemfile b/Gemfile index 37597a3..a7ec820 100644 --- a/Gemfile +++ b/Gemfile @@ -28,11 +28,12 @@ group :development do gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0') gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0') gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9') + gem "json", '<= 2.0.4', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.4.4') gem "puppet-module-posix-default-r#{minor_version}", require: false, platforms: [:ruby] gem "puppet-module-posix-dev-r#{minor_version}", require: false, platforms: [:ruby] gem "puppet-module-win-default-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "puppet-module-win-dev-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "puppet-blacksmith", '~> 3.4', require: false + gem "puppet-blacksmith", '~> 3.4', require: false, platforms: [:ruby] end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] @@ -49,73 +50,24 @@ puppet_type = gem_type(puppet_version) facter_version = ENV['FACTER_GEM_VERSION'] hiera_version = ENV['HIERA_GEM_VERSION'] -def puppet_older_than?(version) - puppet_version = ENV['PUPPET_GEM_VERSION'] - !puppet_version.nil? && - Gem::Version.correct?(puppet_version) && - Gem::Requirement.new("< #{version}").satisfied_by?(Gem::Version.new(puppet_version.dup)) -end - gems = {} gems['puppet'] = location_for(puppet_version) # If facter or hiera versions have been specified via the environment -# variables, use those versions. If not, and if the puppet version is < 3.5.0, -# use known good versions of both for puppet < 3.5.0. -if facter_version - gems['facter'] = location_for(facter_version) -elsif puppet_type == :gem && puppet_older_than?('3.5.0') - gems['facter'] = ['>= 1.6.11', '<= 1.7.5', require: false] -end - -if hiera_version - gems['hiera'] = location_for(ENV['HIERA_GEM_VERSION']) -elsif puppet_type == :gem && puppet_older_than?('3.5.0') - gems['hiera'] = ['>= 1.0.0', '<= 1.3.0', require: false] -end +# variables -if Gem.win_platform? && (puppet_type != :gem || puppet_older_than?('3.5.0')) - # For Puppet gems < 3.5.0 (tested as far back as 3.0.0) on Windows - if puppet_type == :gem - gems['ffi'] = ['1.9.0', require: false] - gems['minitar'] = ['0.5.4', require: false] - gems['win32-eventlog'] = ['0.5.3', '<= 0.6.5', require: false] - gems['win32-process'] = ['0.6.5', '<= 0.7.5', require: false] - gems['win32-security'] = ['~> 0.1.2', '<= 0.2.5', require: false] - gems['win32-service'] = ['0.7.2', '<= 0.8.8', require: false] - else - gems['ffi'] = ['~> 1.9.0', require: false] - gems['minitar'] = ['~> 0.5.4', require: false] - gems['win32-eventlog'] = ['~> 0.5', '<= 0.6.5', require: false] - gems['win32-process'] = ['~> 0.6', '<= 0.7.5', require: false] - gems['win32-security'] = ['~> 0.1', '<= 0.2.5', require: false] - gems['win32-service'] = ['~> 0.7', '<= 0.8.8', require: false] - end - - gems['win32-dir'] = ['~> 0.3', '<= 0.4.9', require: false] - - if RUBY_VERSION.start_with?('1.') - gems['win32console'] = ['1.3.2', require: false] - # sys-admin was removed in Puppet 3.7.0 and doesn't compile under Ruby 2.x - gems['sys-admin'] = ['1.5.6', require: false] - end +gems['facter'] = location_for(facter_version) if facter_version +gems['hiera'] = location_for(hiera_version) if hiera_version - # Puppet < 3.7.0 requires these. - # Puppet >= 3.5.0 gem includes these as requirements. - # The following versions are tested to work with 3.0.0 <= puppet < 3.7.0. - gems['win32-api'] = ['1.4.8', require: false] - gems['win32-taskscheduler'] = ['0.2.2', require: false] - gems['windows-api'] = ['0.4.3', require: false] - gems['windows-pr'] = ['1.2.3', require: false] -elsif Gem.win_platform? +if Gem.win_platform? && puppet_version =~ %r{^(file:///|git://)} # If we're using a Puppet gem on Windows which handles its own win32-xxx gem # dependencies (>= 3.5.0), set the maximum versions (see PUP-6445). gems['win32-dir'] = ['<= 0.4.9', require: false] gems['win32-eventlog'] = ['<= 0.6.5', require: false] gems['win32-process'] = ['<= 0.7.5', require: false] gems['win32-security'] = ['<= 0.2.5', require: false] - gems['win32-service'] = ['<= 0.8.8', require: false] + gems['win32-service'] = ['0.8.8', require: false] end gems.each do |gem_name, gem_params| diff --git a/Rakefile b/Rakefile index 802f67b..d4e36da 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,6 @@ require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' -require 'puppet_blacksmith/rake_tasks' +require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? + +PuppetLint.configuration.send('disable_relative') + diff --git a/manifests/init.pp b/manifests/init.pp index 6b69ecc..06dc0ac 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -202,17 +202,5 @@ class apt ( } # required for adding GPG keys on Debian 9 (and derivatives) - case $facts['os']['name'] { - 'Debian': { - if versioncmp($facts['os']['release']['major'], '9') >= 0 { - ensure_packages(['dirmngr']) - } - } - 'Ubuntu': { - if versioncmp($facts['os']['release']['full'], '17.04') >= 0 { - ensure_packages(['dirmngr']) - } - } - default: { } - } + ensure_packages(['dirmngr']) } diff --git a/manifests/params.pp b/manifests/params.pp index 901340b..b0ad60c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -75,19 +75,13 @@ class apt::params { case $facts['os']['name']{ 'Debian': { - case $facts['os']['release']['full'] { - default: { $backports = { 'location' => 'http://deb.debian.org/debian', 'key' => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', 'repos' => 'main contrib non-free', } - } - } - $ppa_options = undef $ppa_package = undef - } 'Ubuntu': { $backports = { @@ -95,25 +89,8 @@ class apt::params { 'key' => '630239CC130E1A7FD81A27B140976EAF437D05B5', 'repos' => 'main universe multiverse restricted', } - - case $facts['os']['release']['full'] { - '10.04': { - $ppa_options = undef - $ppa_package = 'python-software-properties' - } - '12.04': { - $ppa_options = '-y' - $ppa_package = 'python-software-properties' - } - '14.04', '14.10', '15.04', '15.10', '16.04': { - $ppa_options = '-y' - $ppa_package = 'software-properties-common' - } - default: { - $ppa_options = '-y' - $ppa_package = 'python-software-properties' - } - } + $ppa_options = '-y' + $ppa_package = 'software-properties-common' } undef: { fail('Unable to determine value for fact os["name"]') diff --git a/manifests/source.pp b/manifests/source.pp index 670b830..afbb27a 100644 --- a/manifests/source.pp +++ b/manifests/source.pp @@ -14,7 +14,6 @@ define apt::source( Boolean $notify_update = true, ) { - # This is needed for compat with 1.8.x include ::apt $_before = Apt::Setting["list-${title}"] @@ -29,17 +28,9 @@ define apt::source( $_release = $release } - # Some releases do not support https transport with default installation - $_transport_https_releases = [ 'wheezy', 'jessie', 'stretch', 'trusty', 'xenial' ] - if $ensure == 'present' { if ! $location { fail('cannot create a source entry without specifying a location') - } elsif $_release in $_transport_https_releases { - $method = split($location, '[:\/]+')[0] - if $method == 'https' { - ensure_packages('apt-transport-https') - } } } diff --git a/metadata.json b/metadata.json index d5b31f2..11b2b02 100644 --- a/metadata.json +++ b/metadata.json @@ -17,8 +17,8 @@ { "operatingsystem": "Debian", "operatingsystemrelease": [ - "7", - "8" + "8", + "9" ] }, { @@ -35,6 +35,7 @@ "version_requirement": ">= 4.7.0 < 6.0.0" } ], - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.3.2-0-g07678c8" + "template-url": "https://github.com/puppetlabs/pdk-templates", + "template-ref": "heads/master-0-g34e3266", + "pdk-version": "1.5.0" } diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/01_apt_class_spec.rb similarity index 100% rename from spec/acceptance/class_spec.rb rename to spec/acceptance/01_apt_class_spec.rb diff --git a/spec/acceptance/apt_key_provider_spec.rb b/spec/acceptance/apt_key_provider_spec.rb index 08bf61f..aa78001 100644 --- a/spec/acceptance/apt_key_provider_spec.rb +++ b/spec/acceptance/apt_key_provider_spec.rb @@ -10,17 +10,11 @@ CENTOS_GPG_KEY_LONG_ID = '0946FCA2C105B9DE'.freeze CENTOS_GPG_KEY_FINGERPRINT = 'C1DAC52D1664E8A4386DBA430946FCA2C105B9DE'.freeze CENTOS_REPO_URL = 'ftp.cvut.cz/centos'.freeze CENTOS_GPG_KEY_FILE = 'RPM-GPG-KEY-CentOS-6'.freeze - SHOULD_NEVER_EXIST_ID = 'EF8D349F'.freeze - KEY_CHECK_COMMAND = 'apt-key adv --list-keys --with-colons --fingerprint | grep '.freeze PUPPETLABS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{PUPPETLABS_GPG_KEY_FINGERPRINT}".freeze CENTOS_KEY_CHECK_COMMAND = "#{KEY_CHECK_COMMAND} #{CENTOS_GPG_KEY_FINGERPRINT}".freeze -MAX_TIMEOUT_RETRY = 3 -TIMEOUT_RETRY_WAIT = 5 -TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found} - def populate_default_options_pp(value) default_options_pp = <<-MANIFEST apt_key { 'puppetlabs': @@ -32,15 +26,18 @@ def populate_default_options_pp(value) end def install_key(key) - retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do - shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net \ - --recv-keys #{key}") + retry_on_error_matching do + shell("apt-key adv --keyserver hkps.pool.sks-keyservers.net --recv-keys #{key}") end end def apply_manifest_twice(manifest_pp) - apply_manifest(manifest_pp, catch_failures: true) - apply_manifest(manifest_pp, catch_changes: true) + retry_on_error_matching do + apply_manifest(manifest_pp, catch_failures: true) + end + retry_on_error_matching do + apply_manifest(manifest_pp, catch_changes: true) + end end invalid_key_length_pp = <<-MANIFEST @@ -612,7 +609,7 @@ describe 'apt_key' do end end - context 'when absent, added with long key', unless: (fact('operatingsystem') == 'Debian' && fact('operatingsystemmajrelease') == '6') do + context 'when absent, added with long key' do it 'is removed' do # Install the key first (retry because key pool may timeout) install_key(PUPPETLABS_GPG_KEY_LONG_ID) @@ -630,7 +627,7 @@ describe 'apt_key' do context 'with puppetlabs gpg key' do it 'works' do # Apply the manifest (Retry if timeout error is received from key pool) - retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do + retry_on_error_matching do apply_manifest(gpg_key_pp, catch_failures: true) end @@ -659,7 +656,7 @@ describe 'apt_key' do context 'with hkps.pool.sks-keyservers.net' do it 'works' do # Apply the manifest (Retry if timeout error is received from key pool) - retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do + retry_on_error_matching do apply_manifest(hkps_pool_pp, catch_failures: true) end @@ -670,7 +667,7 @@ describe 'apt_key' do context 'with hkp://hkps.pool.sks-keyservers.net:80' do it 'works' do - retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do + retry_on_error_matching do apply_manifest(hkp_pool_pp, catch_failures: true) end @@ -682,7 +679,7 @@ describe 'apt_key' do context 'with nonexistant.key.server' do it 'fails' do apply_manifest(nonexistant_key_server_pp, expect_failures: true) do |r| - expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host)}) + expect(r.stderr).to match(%r{(Host not found|Couldn't resolve host|No name)}) end end end @@ -721,7 +718,8 @@ describe 'apt_key' do end end - context 'with ftp://' do + # disabled when running in travis, security issues prevent FTP + context 'with ftp://', unless: (ENV['TRAVIS'] == 'true') do before(:each) do shell("apt-key del #{CENTOS_GPG_KEY_LONG_ID}", acceptable_exit_codes: [0, 1, 2]) diff --git a/spec/acceptance/apt_spec.rb b/spec/acceptance/apt_spec.rb index 5505748..7fe1d03 100644 --- a/spec/acceptance/apt_spec.rb +++ b/spec/acceptance/apt_spec.rb @@ -1,24 +1,16 @@ require 'spec_helper_acceptance' -MAX_TIMEOUT_RETRY = 3 -TIMEOUT_RETRY_WAIT = 5 -TIMEOUT_ERROR_MATCHER = %r{no valid OpenPGP data found} - everything_everything_pp = <<-MANIFEST - if $::lsbdistcodename == 'lucid' { - $sources = undef - } else { - $sources = { - 'puppetlabs' => { - 'ensure' => present, - 'location' => 'http://apt.puppetlabs.com', - 'repos' => 'main', - 'key' => { - 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', - 'server' => 'hkps.pool.sks-keyservers.net', - }, + $sources = { + 'puppetlabs' => { + 'ensure' => present, + 'location' => 'http://apt.puppetlabs.com', + 'repos' => 'main', + 'key' => { + 'id' => '6F6B15509CF8E59E6E469F327F438280EF8D349F', + 'server' => 'pool.sks-keyservers.net', }, - } + }, } class { 'apt': update => { @@ -46,11 +38,9 @@ describe 'apt class' do context 'with all the things' do it 'works with no errors' do # Apply the manifest (Retry if timeout error is received from key pool) - retry_on_error_matching(MAX_TIMEOUT_RETRY, TIMEOUT_RETRY_WAIT, TIMEOUT_ERROR_MATCHER) do + retry_on_error_matching do apply_manifest(everything_everything_pp, catch_failures: true) end - - apply_manifest(everything_everything_pp, catch_failures: true) end it 'stills work' do shell('apt-get update') diff --git a/spec/classes/apt_backports_spec.rb b/spec/classes/apt_backports_spec.rb index 33022b9..215faae 100644 --- a/spec/classes/apt_backports_spec.rb +++ b/spec/classes/apt_backports_spec.rb @@ -7,10 +7,10 @@ describe 'apt::backports', type: :class do context 'with defaults on deb' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -19,18 +19,18 @@ describe 'apt::backports', type: :class do is_expected.to contain_apt__source('backports').with(location: 'http://deb.debian.org/debian', key: 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553', repos: 'main contrib non-free', - release: 'wheezy-backports', - pin: { 'priority' => 200, 'release' => 'wheezy-backports' }) + release: 'jessie-backports', + pin: { 'priority' => 200, 'release' => 'jessie-backports' }) } end context 'with defaults on ubuntu' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', - lsbdistcodename: 'trusty', - lsbdistrelease: '14.04', + lsbdistcodename: 'xenial', + lsbdistrelease: '16.04', puppetversion: Puppet.version, } end @@ -39,18 +39,18 @@ describe 'apt::backports', type: :class do is_expected.to contain_apt__source('backports').with(location: 'http://archive.ubuntu.com/ubuntu', key: '630239CC130E1A7FD81A27B140976EAF437D05B5', repos: 'main universe multiverse restricted', - release: 'trusty-backports', - pin: { 'priority' => 200, 'release' => 'trusty-backports' }) + release: 'xenial-backports', + pin: { 'priority' => 200, 'release' => 'xenial-backports' }) } end context 'with everything set' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', - lsbdistcodename: 'trusty', - lsbdistrelease: '14.04', + lsbdistcodename: 'xenial', + lsbdistrelease: '16.04', puppetversion: Puppet.version, } end @@ -75,11 +75,11 @@ describe 'apt::backports', type: :class do context 'when set things with hashes' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', - lsbdistcodename: 'trusty', - lsbdistrelease: '14.04', + lsbdistcodename: 'xenial', + lsbdistrelease: '16.04', puppetversion: Puppet.version, } end @@ -185,11 +185,11 @@ describe 'apt::backports', type: :class do describe 'validation' do let(:facts) do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, lsbdistid: 'Ubuntu', osfamily: 'Debian', - lsbdistcodename: 'trusty', - lsbdistrelease: '14.04', + lsbdistcodename: 'xenial', + lsbdistrelease: '16.04', puppetversion: Puppet.version, } end diff --git a/spec/classes/apt_spec.rb b/spec/classes/apt_spec.rb index 654af4e..011286d 100644 --- a/spec/classes/apt_spec.rb +++ b/spec/classes/apt_spec.rb @@ -236,11 +236,11 @@ machine apt.example.com login aptlogin password supersecret context 'with sources defined on valid osfamily' do let :facts do - { os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04' } }, + { os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'Ubuntu', - lsbdistrelease: '12.04', + lsbdistrelease: '16.04', puppetversion: Puppet.version } end let(:params) do @@ -272,15 +272,15 @@ machine apt.example.com login aptlogin password supersecret is_expected.to contain_apt__setting('list-puppetlabs').with(ensure: 'present') } - it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com precise main$}) } + it { is_expected.to contain_file('/etc/apt/sources.list.d/puppetlabs.list').with_content(%r{^deb http://apt.puppetlabs.com xenial main$}) } end context 'with confs defined on valid osfamily' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'Debian', puppetversion: Puppet.version, } @@ -308,9 +308,9 @@ machine apt.example.com login aptlogin password supersecret context 'with keys defined on valid osfamily' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'Debian', puppetversion: Puppet.version, } @@ -338,11 +338,11 @@ machine apt.example.com login aptlogin password supersecret context 'with ppas defined on valid osfamily' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'ubuntu', - lsbdistrelease: '12.04', + lsbdistrelease: '16.04', puppetversion: Puppet.version, } end @@ -360,9 +360,9 @@ machine apt.example.com login aptlogin password supersecret context 'with settings defined on valid osfamily' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'Debian', puppetversion: Puppet.version, } @@ -381,9 +381,9 @@ machine apt.example.com login aptlogin password supersecret context 'with pins defined on valid osfamily' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '12', full: '12.04.5' } }, + os: { family: 'Debian', name: 'Ubuntu', release: { major: '16', full: '16.04' } }, osfamily: 'Debian', - lsbdistcodename: 'precise', + lsbdistcodename: 'xenial', lsbdistid: 'Debian', puppetversion: Puppet.version, } diff --git a/spec/classes/apt_update_spec.rb b/spec/classes/apt_update_spec.rb index 675bbd2..3fb587e 100644 --- a/spec/classes/apt_update_spec.rb +++ b/spec/classes/apt_update_spec.rb @@ -10,11 +10,11 @@ describe 'apt::update', type: :class do context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -31,10 +31,10 @@ describe 'apt::update', type: :class do context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -55,11 +55,11 @@ describe 'apt::update', type: :class do context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -74,10 +74,10 @@ describe 'apt::update', type: :class do context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -89,17 +89,17 @@ describe 'apt::update', type: :class do end end end - %w[daily weekly].each do |update_frequency| + ['daily', 'weekly'].each do |update_frequency| context "when apt::update['frequency'] has the value of #{update_frequency}" do { 'we are due for a run' => 1_406_660_561, 'the update-success-stamp file does not exist' => -1 }.each_pair do |desc, factval| context "when $::apt_update_last_success indicates #{desc}" do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', apt_update_last_success: factval, - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -114,10 +114,10 @@ describe 'apt::update', type: :class do context 'when the $::apt_update_last_success fact has a recent value' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', apt_update_last_success: Time.now.to_i, puppetversion: Puppet.version, } @@ -132,10 +132,10 @@ describe 'apt::update', type: :class do context 'when $::apt_update_last_success is nil' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', apt_update_last_success: nil, puppetversion: Puppet.version, } diff --git a/spec/default_facts.yml b/spec/default_facts.yml new file mode 100644 index 0000000..3248be5 --- /dev/null +++ b/spec/default_facts.yml @@ -0,0 +1,8 @@ +# Use default_module_facts.yml for module specific facts. +# +# Facts specified here will override the values provided by rspec-puppet-facts. +--- +concat_basedir: "/tmp" +ipaddress: "172.16.254.254" +is_pe: false +macaddress: "AA:AA:AA:AA:AA:AA" diff --git a/spec/defines/conf_spec.rb b/spec/defines/conf_spec.rb index d79cb22..7f75fd9 100644 --- a/spec/defines/conf_spec.rb +++ b/spec/defines/conf_spec.rb @@ -5,10 +5,10 @@ describe 'apt::conf', type: :define do end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end diff --git a/spec/defines/key_compat_spec.rb b/spec/defines/key_compat_spec.rb index 43ccbbc..aee5855 100644 --- a/spec/defines/key_compat_spec.rb +++ b/spec/defines/key_compat_spec.rb @@ -23,7 +23,7 @@ describe 'apt::key', type: :define do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', puppetversion: Puppet.version, diff --git a/spec/defines/key_spec.rb b/spec/defines/key_spec.rb index 6a5a89f..d196063 100644 --- a/spec/defines/key_spec.rb +++ b/spec/defines/key_spec.rb @@ -43,10 +43,10 @@ describe 'apt::key' do let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -317,7 +317,7 @@ describe 'apt::key' do end context 'with invalid ensure' do - %w[foo aabsent absenta apresent presenta].each do |param| + ['foo', 'aabsent', 'absenta', 'apresent', 'presenta'].each do |param| let :params do { ensure: param, diff --git a/spec/defines/pin_spec.rb b/spec/defines/pin_spec.rb index 2329e9a..1d0c6b1 100644 --- a/spec/defines/pin_spec.rb +++ b/spec/defines/pin_spec.rb @@ -5,10 +5,10 @@ describe 'apt::pin', type: :define do end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end diff --git a/spec/defines/ppa_spec.rb b/spec/defines/ppa_spec.rb index b534186..4978221 100644 --- a/spec/defines/ppa_spec.rb +++ b/spec/defines/ppa_spec.rb @@ -7,9 +7,9 @@ describe 'apt::ppa' do describe 'defaults' do let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '41.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', @@ -23,7 +23,7 @@ describe 'apt::ppa' do it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow+type').that_notifies('Class[Apt::Update]').with(environment: [], command: '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow+type', # rubocop:disable Metrics/LineLength - unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-natty.list', # rubocop:disable Metrics/LineLength + unless: '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow_type-trusty.list', # rubocop:disable Metrics/LineLength user: 'root', logoutput: 'on_failure') } @@ -65,9 +65,9 @@ describe 'apt::ppa' do end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', @@ -81,53 +81,13 @@ describe 'apt::ppa' do it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength 'user' => 'root', 'logoutput' => 'on_failure') } it { - is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') - } - end - - describe 'package_manage => true, multiple ppas, MODULES-2873' do - let :pre_condition do - 'class { "apt": } - apt::ppa {"ppa:user/foo": - package_manage => true - }' - end - let :facts do - { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', - operatingsystem: 'Ubuntu', - osfamily: 'Debian', - lsbdistid: 'Ubuntu', - puppetversion: Puppet.version, - } - end - let :params do - { - package_manage: true, - } - end - - let(:title) { 'ppa:user/bar' } - - it { is_expected.to contain_package('python-software-properties') } - it { - is_expected.to contain_exec('add-apt-repository-ppa:user/bar').that_notifies('Class[Apt::Update]').with('environment' => [], - 'command' => '/usr/bin/add-apt-repository -y ppa:user/bar', - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/user-bar-natty.list', - 'user' => 'root', - 'logoutput' => 'on_failure') - } - - it { - is_expected.to contain_file('/etc/apt/sources.list.d/user-bar-natty.list').that_requires('Exec[add-apt-repository-ppa:user/bar]').with('ensure' => 'file') + is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end @@ -137,9 +97,9 @@ describe 'apt::ppa' do end let :facts do { - os: { family: 'Debian', name: 'Ubuntu', release: { major: '11', full: '11.04' } }, - lsbdistrelease: '11.04', - lsbdistcodename: 'natty', + os: { family: 'Debian', name: 'Ubuntu', release: { major: '14', full: '14.04' } }, + lsbdistrelease: '14.04', + lsbdistcodename: 'trusty', operatingsystem: 'Ubuntu', osfamily: 'Debian', lsbdistid: 'Ubuntu', @@ -158,13 +118,13 @@ describe 'apt::ppa' do it { is_expected.to contain_exec('add-apt-repository-ppa:needs/such.substitution/wow').that_notifies('Class[Apt::Update]').with('environment' => [], 'command' => '/usr/bin/add-apt-repository -y ppa:needs/such.substitution/wow', # rubocop:disable Metrics/LineLength - 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-natty.list', # rubocop:disable Metrics/LineLength + 'unless' => '/usr/bin/test -f /etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list', # rubocop:disable Metrics/LineLength 'user' => 'root', 'logoutput' => 'on_failure') } it { - is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-natty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') + is_expected.to contain_file('/etc/apt/sources.list.d/needs-such_substitution-wow-trusty.list').that_requires('Exec[add-apt-repository-ppa:needs/such.substitution/wow]').with('ensure' => 'file') } end diff --git a/spec/defines/setting_spec.rb b/spec/defines/setting_spec.rb index 1a94de7..2d70414 100644 --- a/spec/defines/setting_spec.rb +++ b/spec/defines/setting_spec.rb @@ -4,9 +4,9 @@ describe 'apt::setting' do let(:pre_condition) { 'class { "apt": }' } let :facts do { - os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, - lsbdistrelease: '7.0', - lsbdistcodename: 'wheezy', + os: { distro: { codename: 'wheezy' }, family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, + lsbdistrelease: '8.0', + lsbdistcodename: 'jessie', operatingsystem: 'Debian', osfamily: 'Debian', lsbdistid: 'Debian', @@ -77,10 +77,10 @@ describe 'apt::setting' do end let(:facts) do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end diff --git a/spec/defines/source_compat_spec.rb b/spec/defines/source_compat_spec.rb index f89f4be..907fde1 100644 --- a/spec/defines/source_compat_spec.rb +++ b/spec/defines/source_compat_spec.rb @@ -10,9 +10,9 @@ describe 'apt::source', type: :define do context 'with mostly defaults' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -26,16 +26,16 @@ describe 'apt::source', type: :define do end it { - is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb-src http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with no defaults' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -74,9 +74,9 @@ describe 'apt::source', type: :define do context 'when allow_unsigned true' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -89,15 +89,15 @@ describe 'apt::source', type: :define do } end - it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ wheezy main\n}) } + it { is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[trusted=yes\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with architecture equals x86_64' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -110,16 +110,16 @@ describe 'apt::source', type: :define do end it { - is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with_content(%r{# my_source\ndeb \[arch=x86_64\] http://debian.mirror.iweb.ca/debian/ jessie main\n}) } end context 'with ensure => absent' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -139,7 +139,7 @@ describe 'apt::source', type: :define do context 'with no release' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', puppetversion: Puppet.version, diff --git a/spec/defines/source_spec.rb b/spec/defines/source_spec.rb index a9077e9..ee88132 100644 --- a/spec/defines/source_spec.rb +++ b/spec/defines/source_spec.rb @@ -15,9 +15,9 @@ describe 'apt::source' do context 'without location' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, osfamily: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', puppetversion: Puppet.version, } end @@ -29,9 +29,9 @@ describe 'apt::source' do context 'with location' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -47,12 +47,12 @@ describe 'apt::source' do describe 'no defaults' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', operatingsystem: 'Debian', - lsbdistrelease: '7.0', + lsbdistrelease: '8.0', puppetversion: Puppet.version, } end @@ -68,7 +68,7 @@ describe 'apt::source' do end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{hello.there jessie main\n}) } it { is_expected.to contain_file('/etc/apt/sources.list.d/my_source.list').that_notifies('Class[Apt::Update]') } @@ -183,9 +183,9 @@ describe 'apt::source' do context 'with allow_unsigned true' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -198,7 +198,7 @@ describe 'apt::source' do end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb \[trusted=yes\] hello.there jessie main\n}) } end @@ -229,9 +229,9 @@ describe 'apt::source' do let :facts do { architecture: 'amd64', - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -244,16 +244,16 @@ describe 'apt::source' do end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb-src hello.there jessie main\n}) } end context 'with include_src => true' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -266,16 +266,16 @@ describe 'apt::source' do end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there wheezy main\ndeb-src hello.there wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{# my_source\ndeb hello.there jessie main\ndeb-src hello.there jessie main\n}) } end context 'with include deb => false' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'debian', puppetversion: Puppet.version, } @@ -296,9 +296,9 @@ describe 'apt::source' do context 'with include src => true and include deb => false' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'debian', puppetversion: Puppet.version, } @@ -311,17 +311,17 @@ describe 'apt::source' do end it { - is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there wheezy main\n}) + is_expected.to contain_apt__setting('list-my_source').with(ensure: 'present').with_content(%r{deb-src hello.there jessie main\n}) } - it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there wheezy main\n}) } + it { is_expected.to contain_apt__setting('list-my_source').without_content(%r{deb hello.there jessie main\n}) } end context 'with ensure => absent' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -341,7 +341,7 @@ describe 'apt::source' do context 'with no release' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', puppetversion: Puppet.version, @@ -357,7 +357,7 @@ describe 'apt::source' do context 'with release is empty string' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', osfamily: 'Debian', puppetversion: Puppet.version, @@ -371,9 +371,9 @@ describe 'apt::source' do context 'with invalid pin' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -393,9 +393,9 @@ describe 'apt::source' do context 'with notify_update = undef (default)' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -412,9 +412,9 @@ describe 'apt::source' do context 'with notify_update = true' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } @@ -432,9 +432,9 @@ describe 'apt::source' do context 'with notify_update = false' do let :facts do { - os: { family: 'Debian', name: 'Debian', release: { major: '7', full: '7.0' } }, + os: { family: 'Debian', name: 'Debian', release: { major: '8', full: '8.0' } }, lsbdistid: 'Debian', - lsbdistcodename: 'wheezy', + lsbdistcodename: 'jessie', osfamily: 'Debian', puppetversion: Puppet.version, } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 15266c2..e117192 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,5 +1,13 @@ + require 'puppetlabs_spec_helper/module_spec_helper' require 'rspec-puppet-facts' + +begin + require 'spec_helper_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_local.rb')) +rescue LoadError => loaderror + warn "Could not require spec_helper_local: #{loaderror.message}" +end + include RspecPuppetFacts default_facts = { @@ -20,4 +28,9 @@ end RSpec.configure do |c| c.default_facts = default_facts + c.before :each do + # set to strictest setting for testing + # by default Puppet runs at warning level + Puppet.settings[:strict] = :warning + end end diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb index 2ec2dba..763f03b 100644 --- a/spec/spec_helper_acceptance.rb +++ b/spec/spec_helper_acceptance.rb @@ -1,58 +1,17 @@ require 'beaker-rspec' require 'beaker/puppet_install_helper' require 'beaker/module_install_helper' - -def install_bolt_on(hosts) - on(hosts, "/opt/puppetlabs/puppet/bin/gem install --source http://rubygems.delivery.puppetlabs.net bolt -v '> 0.0.1'", acceptable_exit_codes: [0, 1]).stdout -end - -def pe_install? - ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i -end +require 'beaker-task_helper' run_puppet_install_helper install_bolt_on(hosts) unless pe_install? install_module_on(hosts) install_module_dependencies_on(hosts) -UNSUPPORTED_PLATFORMS = %w[RedHat Suse windows AIX Solaris].freeze - -DEFAULT_PASSWORD = if default[:hypervisor] == 'vagrant' - 'vagrant' - elsif default[:hypervisor] == 'vcloud' - 'Qu@lity!' - end - -def puppet_version - (on default, puppet('--version')).output.chomp -end - -def run_puppet_access_login(user:, password: - '~!@#$%^*-/ aZ', lifetime: '5y') - on(master, puppet('access', 'login', '--username', user, '--lifetime', lifetime), stdin: password) -end - -def run_task(task_name:, params: nil, password: DEFAULT_PASSWORD) - if pe_install? - run_puppet_task(task_name: task_name, params: params) - else - run_bolt_task(task_name: task_name, params: params, password: password) - end -end - -def run_bolt_task(task_name:, params: nil, password: DEFAULT_PASSWORD) - on(master, "/opt/puppetlabs/puppet/bin/bolt task run #{task_name} --modules /etc/puppetlabs/code/modules/service --nodes localhost --password #{password} #{params}", acceptable_exit_codes: [0, 1]).stdout # rubocop:disable Metrics/LineLength -end - -def run_puppet_task(task_name:, params: nil) - on(master, puppet('task', 'run', task_name, '--nodes', fact_on(master, 'fqdn'), params.to_s), acceptable_exit_codes: [0, 1]).stdout -end - -def expect_multiple_regexes(result:, regexes:) - regexes.each do |regex| - expect(result).to match(regex) - end -end +UNSUPPORTED_PLATFORMS = ['RedHat', 'Suse', 'windows', 'AIX', 'Solaris'].freeze +MAX_RETRY_COUNT = 12 +RETRY_WAIT = 10 +ERROR_MATCHER = %r{(no valid OpenPGP data found|keyserver timed out|keyserver receive failed)} # This method allows a block to be passed in and if an exception is raised # that matches the 'error_matcher' matcher, the block will wait a set number @@ -65,9 +24,10 @@ end # retry_on_error_matching(3, 5, /OpenGPG Error/) do # apply_manifest(pp, :catch_failures => true) # end -def retry_on_error_matching(max_retry_count = 3, retry_wait_interval_secs = 5, error_matcher = nil) +def retry_on_error_matching(max_retry_count = MAX_RETRY_COUNT, retry_wait_interval_secs = RETRY_WAIT, error_matcher = ERROR_MATCHER) try = 0 begin + puts "retry_on_error_matching: try #{try}" unless try.zero? try += 1 yield rescue StandardError => e diff --git a/spec/unit/facter/apt_dist_package_security_updates_spec.rb b/spec/unit/facter/apt_dist_package_security_updates_spec.rb index 7f4f16a..d6f0a9f 100644 --- a/spec/unit/facter/apt_dist_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_dist_package_security_updates_spec.rb @@ -53,7 +53,7 @@ describe 'apt_package_security_dist_updates fact' do if Facter.version < '2.0.0' it { is_expected.to eq('extremetuxracer,vim') } else - it { is_expected.to eq(%w[extremetuxracer vim]) } + it { is_expected.to eq(['extremetuxracer', 'vim']) } end end end diff --git a/spec/unit/facter/apt_package_security_updates_spec.rb b/spec/unit/facter/apt_package_security_updates_spec.rb index 1cd992d..1bc1fda 100644 --- a/spec/unit/facter/apt_package_security_updates_spec.rb +++ b/spec/unit/facter/apt_package_security_updates_spec.rb @@ -51,7 +51,7 @@ describe 'apt_package_security_updates fact' do if Facter.version < '2.0.0' it { is_expected.to eq('tzdata,curl') } else - it { is_expected.to eq(%w[tzdata curl]) } + it { is_expected.to eq(['tzdata', 'curl']) } end end end