From 31788086b9ddd97e09429aa7ff00cfdf4a8b6ff3 Mon Sep 17 00:00:00 2001 From: Rehan Mahmood Date: Sun, 25 Aug 2019 18:45:11 -0400 Subject: [PATCH] - Added support for Debian 10. - Updated os support matrix. - Updated `pdk` templates. --- .gitignore | 3 + .pdkignore | 18 +++++ .puppet-lint.rc | 1 + .rubocop.yml | 8 +- .sync.yml | 3 +- .travis.yml | 79 +++++++++++++------ .vscode/extensions.json | 6 ++ Gemfile | 20 ++--- Rakefile | 5 +- appveyor.yml | 9 +-- metadata.json | 8 +- spec/acceptance/nodesets/docker/centos-7.yml | 19 ++--- spec/acceptance/nodesets/docker/debian-10.yml | 13 +++ spec/acceptance/nodesets/docker/debian-8.yml | 17 ++-- spec/acceptance/nodesets/docker/debian-9.yml | 18 +++-- .../nodesets/docker/ubuntu-14.04.yml | 21 ++--- .../nodesets/docker/ubuntu-16.04.yml | 18 +++-- .../nodesets/docker/ubuntu-18.04.yml | 18 +++-- spec/spec_helper.rb | 12 ++- 19 files changed, 194 insertions(+), 102 deletions(-) create mode 100644 .puppet-lint.rc create mode 100644 .vscode/extensions.json create mode 100644 spec/acceptance/nodesets/docker/debian-10.yml diff --git a/.gitignore b/.gitignore index 650022e..2767022 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml diff --git a/.pdkignore b/.pdkignore index 650022e..e6215cd 100644 --- a/.pdkignore +++ b/.pdkignore @@ -22,3 +22,21 @@ /convert_report.txt /update_report.txt .DS_Store +.project +.envrc +/inventory.yaml +/appveyor.yml +/.fixtures.yml +/Gemfile +/.gitattributes +/.gitignore +/.gitlab-ci.yml +/.pdkignore +/Rakefile +/rakelib/ +/.rspec +/.rubocop.yml +/.travis.yml +/.yardopts +/spec/ +/.vscode/ diff --git a/.puppet-lint.rc b/.puppet-lint.rc new file mode 100644 index 0000000..cc96ece --- /dev/null +++ b/.puppet-lint.rc @@ -0,0 +1 @@ +--relative diff --git a/.rubocop.yml b/.rubocop.yml index 98b298d..de29175 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,5 +1,7 @@ --- -require: rubocop-rspec +require: +- rubocop-rspec +- rubocop-i18n AllCops: DisplayCopNames: true TargetRubyVersion: '2.1' @@ -20,10 +22,12 @@ AllCops: Metrics/LineLength: Description: People have wide screens, use them. Max: 200 +GetText: + Enabled: false GetText/DecorateString: Description: We don't want to decorate test output. Exclude: - - spec/* + - spec/**/* RSpec/BeforeAfterAll: Description: Beware of using after(:all) as it may cause state to leak between tests. A necessary evil in acceptance testing. diff --git a/.sync.yml b/.sync.yml index 8c5d149..b506147 100644 --- a/.sync.yml +++ b/.sync.yml @@ -24,7 +24,8 @@ - set: docker/ubuntu-18.04 - set: docker/ubuntu-16.04 - set: docker/ubuntu-14.04 -# - set: docker/debian-9 + - set: docker/debian-10 + - set: docker/debian-9 - set: docker/debian-8 - set: docker/centos-7 docker_defaults: diff --git a/.travis.yml b/.travis.yml index 21996f5..bd5035c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,79 +1,108 @@ --- -sudo: false -dist: trusty +dist: xenial language: ruby cache: bundler before_install: - bundle -v - rm -f Gemfile.lock - - gem update --system + - gem update --system $RUBYGEMS_VERSION - gem --version - bundle -v script: - 'bundle exec rake $CHECK' bundler_args: rvm: - - 2.5.1 -env: - global: - - BEAKER_PUPPET_COLLECTION=puppet6 PUPPET_GEM_VERSION="~> 6.0" + - 2.5.3 +stages: + - static + - spec + - acceptance + - + if: tag =~ ^v\d + name: deploy matrix: fast_finish: true include: - + bundler_args: --with system_tests dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-18.04 BEAKER_TESTMODE=apply - rvm: 2.5.1 + rvm: 2.5.3 script: bundle exec rake beaker services: docker + stage: acceptance sudo: required - + bundler_args: --with system_tests dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-16.04 BEAKER_TESTMODE=apply - rvm: 2.5.1 + rvm: 2.5.3 script: bundle exec rake beaker services: docker + stage: acceptance sudo: required - + bundler_args: --with system_tests dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply - rvm: 2.5.1 + rvm: 2.5.3 script: bundle exec rake beaker services: docker + stage: acceptance sudo: required - + bundler_args: --with system_tests + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-10 BEAKER_TESTMODE=apply + rvm: 2.5.3 + script: bundle exec rake beaker + services: docker + stage: acceptance + sudo: required + - + bundler_args: --with system_tests + dist: trusty + env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-9 BEAKER_TESTMODE=apply + rvm: 2.5.3 + script: bundle exec rake beaker + services: docker + stage: acceptance + sudo: required + - + bundler_args: --with system_tests dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/debian-8 BEAKER_TESTMODE=apply - rvm: 2.5.1 + rvm: 2.5.3 script: bundle exec rake beaker services: docker + stage: acceptance sudo: required - + bundler_args: --with system_tests dist: trusty env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply - rvm: 2.5.1 + rvm: 2.5.3 script: bundle exec rake beaker services: docker + stage: acceptance sudo: required - - env: CHECK="syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop" - - - env: CHECK=parallel_spec + env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint" + stage: static - env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec - rvm: 2.4.4 + rvm: 2.4.5 + stage: spec + - + env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec + rvm: 2.5.3 + stage: spec + - + env: DEPLOY_TO_FORGE=yes + stage: deploy branches: only: - master - /^v\d/ notifications: email: false -deploy: - provider: puppetforge - user: puppet - password: - secure: "" - on: - tags: true - all_branches: true - condition: "$DEPLOY_TO_FORGE = yes" diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..6177782 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "jpogran.puppet-vscode", + "rebornix.Ruby" + ] +} diff --git a/Gemfile b/Gemfile index ad54d2f..ab11400 100644 --- a/Gemfile +++ b/Gemfile @@ -17,15 +17,17 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments minor_version = ruby_version_segments[0..1].join('.') group :development do - gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') - 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 "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0') + 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::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-posix-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:ruby] + gem "puppet-module-win-default-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "puppet-module-win-dev-r#{minor_version}", '~> 0.3', require: false, platforms: [:mswin, :mingw, :x64_mingw] end group :system_tests do gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby] diff --git a/Rakefile b/Rakefile index a6b14c5..d9b223c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'puppetlabs_spec_helper/rake_tasks' require 'puppet-syntax/tasks/puppet-syntax' require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any? @@ -14,7 +15,7 @@ end def changelog_project return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = nil || JSON.load(File.read('metadata.json'))['name'] + returnVal = nil || JSON.load(File.read('metadata.json'))['source'].match(%r{.*/([^/]*)})[1] raise "unable to find the changelog_project in .sync.yml or the name in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator project:#{returnVal}" returnVal @@ -22,7 +23,7 @@ end def changelog_future_release return unless Rake.application.top_level_tasks.include? "changelog" - returnVal = JSON.load(File.read('metadata.json'))['version'] + returnVal = "v%s" % JSON.load(File.read('metadata.json'))['version'] raise "unable to find the future_release (version) in metadata.json" if returnVal.nil? puts "GitHubChangelogGenerator future_release:#{returnVal}" returnVal diff --git a/appveyor.yml b/appveyor.yml index f14e28d..ec38949 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,7 @@ version: 1.1.x.{build} branches: only: - master + - release skip_commits: message: /^\(?doc\)?.*/ clone_depth: 10 @@ -17,14 +18,6 @@ environment: - RUBY_VERSION: 24-x64 CHECK: syntax lint metadata_lint check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop - - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VERSION: 21 - CHECK: parallel_spec - - - PUPPET_GEM_VERSION: ~> 4.0 - RUBY_VERSION: 21-x64 - CHECK: parallel_spec - PUPPET_GEM_VERSION: ~> 5.0 RUBY_VERSION: 24 diff --git a/metadata.json b/metadata.json index 086aef8..722854d 100644 --- a/metadata.json +++ b/metadata.json @@ -121,7 +121,7 @@ "Public Key Infrastructure", "Certificate Managment" ], - "pdk-version": "1.8.0", - "template-url": "file:///opt/puppetlabs/pdk/share/cache/pdk-templates.git", - "template-ref": "1.8.0-0-g0d9da00" -} \ No newline at end of file + "pdk-version": "1.12.0", + "template-url": "pdk-default#1.12.0", + "template-ref": "1.12.0-0-g55d9ae2" +} diff --git a/spec/acceptance/nodesets/docker/centos-7.yml b/spec/acceptance/nodesets/docker/centos-7.yml index a3333aa..5932da9 100644 --- a/spec/acceptance/nodesets/docker/centos-7.yml +++ b/spec/acceptance/nodesets/docker/centos-7.yml @@ -1,12 +1,13 @@ HOSTS: - centos-7-x64: - platform: el-7-x86_64 - hypervisor: docker + centos7-64: + docker_cmd: + - "/sbin/init" image: centos:7 - docker_preserve_image: true - docker_cmd: '["/usr/sbin/init"]' - # install various tools required to get the image up to usable levels + platform: el-7-x86_64 + packaging_platform: el-7-x86_64 docker_image_commands: - - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - yum install -y crontabs initscripts iproute openssl sysvinit-tools tar wget + which ss + hypervisor: docker + roles: [] diff --git a/spec/acceptance/nodesets/docker/debian-10.yml b/spec/acceptance/nodesets/docker/debian-10.yml new file mode 100644 index 0000000..82794d7 --- /dev/null +++ b/spec/acceptance/nodesets/docker/debian-10.yml @@ -0,0 +1,13 @@ +HOSTS: + debian10-64: + docker_cmd: + - "/sbin/init" + image: debian:10 + platform: debian-10-amd64 + packaging_platform: debian-10-amd64 + docker_image_commands: + - cp /bin/true /sbin/agetty + - rm -f /usr/sbin/policy-rc.d + - apt-get update && apt-get install -y cron locales-all net-tools wget systemd-sysv + gnupg + hypervisor: docker diff --git a/spec/acceptance/nodesets/docker/debian-8.yml b/spec/acceptance/nodesets/docker/debian-8.yml index df5c319..45b25aa 100644 --- a/spec/acceptance/nodesets/docker/debian-8.yml +++ b/spec/acceptance/nodesets/docker/debian-8.yml @@ -1,11 +1,12 @@ HOSTS: - debian-8-x64: - platform: debian-8-amd64 - hypervisor: docker + debian8-64: + docker_cmd: + - "/sbin/init" image: debian:8 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' + platform: debian-8-amd64 + packaging_platform: debian-8-amd64 docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - rm -f /usr/sbin/policy-rc.d + - apt-get update && apt-get install -y cron locales-all net-tools wget + hypervisor: docker diff --git a/spec/acceptance/nodesets/docker/debian-9.yml b/spec/acceptance/nodesets/docker/debian-9.yml index 2fcabb5..f420fe2 100644 --- a/spec/acceptance/nodesets/docker/debian-9.yml +++ b/spec/acceptance/nodesets/docker/debian-9.yml @@ -1,11 +1,13 @@ HOSTS: - debian-9-x64: - platform: debian-9-amd64 - hypervisor: docker + debian9-64: + docker_cmd: + - "/sbin/init" image: debian:9 - docker_preserve_image: true -# docker_cmd: '["/sbin/init"]' + platform: debian-9-amd64 + packaging_platform: debian-9-amd64 docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - rm -f /usr/sbin/policy-rc.d + - apt-get update && apt-get install -y cron locales-all net-tools wget systemd-sysv + gnupg + hypervisor: docker diff --git a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml index b1efa58..51c5935 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-14.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-14.04.yml @@ -1,12 +1,15 @@ HOSTS: - ubuntu-1404-x64: - platform: ubuntu-14.04-amd64 - hypervisor: docker + ubuntu1404-64: + docker_cmd: + - "/sbin/init" image: ubuntu:14.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' + platform: ubuntu-14.04-amd64 + packaging_platform: ubuntu-14.04-amd64 docker_image_commands: - # ensure that upstart is booting correctly in the container - - 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - rm /usr/sbin/policy-rc.d + - rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl + - apt-get install -y net-tools wget apt-transport-https + - locale-gen en_US.UTF-8 + - echo LANG=en_US.UTF-8 > /etc/default/locale + hypervisor: docker diff --git a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml index f2ca648..1191401 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-16.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-16.04.yml @@ -1,11 +1,13 @@ HOSTS: - ubuntu-1604-x64: - platform: ubuntu-16.04-amd64 - hypervisor: docker + ubuntu1604-64: + docker_cmd: + - "/sbin/init" image: ubuntu:16.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' + platform: ubuntu-16.04-amd64 + packaging_platform: ubuntu-16.04-amd64 docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - apt-get install -y net-tools wget locales apt-transport-https + - locale-gen en_US.UTF-8 + - echo LANG=en_US.UTF-8 > /etc/default/locale + hypervisor: docker diff --git a/spec/acceptance/nodesets/docker/ubuntu-18.04.yml b/spec/acceptance/nodesets/docker/ubuntu-18.04.yml index ba0dafd..33d6aca 100644 --- a/spec/acceptance/nodesets/docker/ubuntu-18.04.yml +++ b/spec/acceptance/nodesets/docker/ubuntu-18.04.yml @@ -1,11 +1,13 @@ HOSTS: - ubuntu-1804-x64: - platform: ubuntu-18.04-amd64 - hypervisor: docker + ubuntu1804-64: + docker_cmd: + - "/sbin/init" image: ubuntu:18.04 - docker_preserve_image: true - docker_cmd: '["/sbin/init"]' + platform: ubuntu-18.04-amd64 + packaging_platform: ubuntu-18.04-amd64 docker_image_commands: - - 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen' -CONFIG: - trace_limit: 200 + - cp /bin/true /sbin/agetty + - apt-get install -y net-tools wget locales apt-transport-https iproute2 gnupg + - locale-gen en_US.UTF-8 + - echo LANG=en_US.UTF-8 > /etc/default/locale + hypervisor: docker diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 35654b3..feb5720 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,12 +19,17 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f))) + default_facts.merge!(YAML.safe_load(File.read(f), [], [], true)) rescue => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end end +# read default_facts and merge them over what is provided by facterdb +default_facts.each do |fact, value| + add_custom_fact fact, value +end + RSpec.configure do |c| c.default_facts = default_facts c.before :each do @@ -32,8 +37,13 @@ # by default Puppet runs at warning level Puppet.settings[:strict] = :warning end + c.filter_run_excluding(bolt: true) unless ENV['GEM_BOLT'] + c.after(:suite) do + end end +# Ensures that a module is defined +# @param module_name Name of the module def ensure_module_defined(module_name) module_name.split('::').reduce(Object) do |last_module, next_module| last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module, false)