From b3660705bdee3f80f2ea0fab5deaa5bec43a9ebc Mon Sep 17 00:00:00 2001 From: Martin Ewings Date: Mon, 12 Aug 2019 15:22:26 +0100 Subject: [PATCH 1/3] pdk 1.12 update --- .rubocop.yml | 8 ++++++-- .travis.yml | 2 +- .vscode/extensions.json | 6 ++++++ Gemfile | 21 +++++++++++---------- Rakefile | 2 +- metadata.json | 7 ++++--- spec/spec_helper.rb | 7 +++++++ 7 files changed, 36 insertions(+), 17 deletions(-) create mode 100644 .vscode/extensions.json diff --git a/.rubocop.yml b/.rubocop.yml index f5a6c2a..3cd2b0e 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' @@ -19,10 +21,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/.travis.yml b/.travis.yml index 4616022..2411608 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ --- -dist: trusty +dist: xenial language: ruby cache: bundler before_install: 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 6b91b16..b347f05 100644 --- a/Gemfile +++ b/Gemfile @@ -17,16 +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::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 "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 2e7ee92..f165ee1 100644 --- a/Rakefile +++ b/Rakefile @@ -15,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 diff --git a/metadata.json b/metadata.json index 2208ab4..0559f16 100644 --- a/metadata.json +++ b/metadata.json @@ -91,7 +91,8 @@ "version_requirement": ">= 5.3.2 < 7.0.0" } ], - "pdk-version": "1.11.0", - "template-url": "https://github.com/puppetlabs/pdk-templates#1.10.0", - "template-ref": "1.10.0-0-gbba9ac3" + "pdk-version": "1.12.0", + "template-url": "https://github.com/puppetlabs/pdk-templates#1.12.0", + "template-ref": "1.12.0-0-g55d9ae2" } + diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 93b25ec..feb5720 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,6 +25,11 @@ 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 @@ -37,6 +42,8 @@ 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) From 772e6f46855e4d312b15db2f260e258f32c6ce36 Mon Sep 17 00:00:00 2001 From: Martin Ewings Date: Mon, 12 Aug 2019 17:02:04 +0100 Subject: [PATCH 2/3] fix kb0299 for SC2242 --- tasks/kb0299_regen_master_cert.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/kb0299_regen_master_cert.sh b/tasks/kb0299_regen_master_cert.sh index ba41f16..54ec91a 100644 --- a/tasks/kb0299_regen_master_cert.sh +++ b/tasks/kb0299_regen_master_cert.sh @@ -16,10 +16,10 @@ exit_if_compile_master() { grep reverse-proxy-ca-service /etc/puppetlabs/puppetserver/bootstrap.cfg 2>&1 /dev/null if [ $? -eq 0 ]; then echo "Target server appears to be a PE compile master. This script is intended to be targeted only at a PE Master of Masters. Exiting." - exit -1 + exit 255 elif [ $? -eq 2 ]; then echo "Target server does not appear to be a PE master. This script is intended to be targeted only at a PE Master of Masters. Exiting." - exit -1 + exit 255 fi } @@ -39,7 +39,7 @@ check_dns_alt_names() { if ! grep "pe_install::puppet_master_dnsaltname.*${tmphost}" /etc/puppetlabs/enterprise/conf.d/pe.conf > /dev/null 2>&1 then echo "'${tmphost}' is set up as a DNS alt name in the existing certificate, but is not present in the 'pe_install::puppet_master_dnsaltnames' setting of '/etc/puppetlabs/enterprise/conf.d/pe.conf'. Please add it to continue, or use the 'dnsaltname_override' task parameter to skip this check." - exit -1 + exit 255 fi done } @@ -62,7 +62,7 @@ fi if [ ! -x $PUPPETCMD ]; then echo "Unable to locate executable Puppet command at ${PUPPETCMD}" - exit -1 + exit 255 fi # Back up the SSL directories From a6838b1ff35aae250b220efa2f8ee0fcca32be4e Mon Sep 17 00:00:00 2001 From: Martin Ewings Date: Mon, 12 Aug 2019 17:10:38 +0100 Subject: [PATCH 3/3] fix kb0263 for SC2242 --- tasks/kb0263_rename_pe_master.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tasks/kb0263_rename_pe_master.sh b/tasks/kb0263_rename_pe_master.sh index c9324d9..30d1569 100644 --- a/tasks/kb0263_rename_pe_master.sh +++ b/tasks/kb0263_rename_pe_master.sh @@ -20,7 +20,7 @@ stopsvc() { if ! $PUPPETCMD resource service "$service" ensure=stopped then echo "Unable to stop '${service}'. Exiting" - exit -1 + exit 255 fi } @@ -31,31 +31,31 @@ tar -cvf "/etc/puppetlabs/puppet/ssl_$(date +%Y-%m-%d-%M-%S).tar.gz" /etc/puppet grep reverse-proxy-ca-service /etc/puppetlabs/puppetserver/bootstrap.cfg 2>&1 /dev/null if [ $? -eq 0 ]; then echo "Target server appears to be a PE compile master. This script is intended to be targeted only at a PE Master of Masters. Exiting." - exit -1 + exit 255 elif [ $? -eq 2 ]; then echo "Target server does not appear to be a PE master. This script is intended to be targeted only at a PE Master of Masters. Exiting." - exit -1 + exit 255 fi if [ ! -x $PUPPETCMD ]; then echo "Unable to locate executable Puppet command at ${PUPPETCMD}" - exit -1 + exit 255 fi if [ -z "$HOSTNAME" ]; then echo "'hostname -f' is returning an empty string. Perhaps name resolution is not configured?" - exit -1 + exit 255 fi if [ "$HOSTNAME" = "$(puppet config print certname)" ]; then echo "This script assumes the hostname has already been changed. The hostname currently matches the certname in puppet.conf. Exiting." - exit -1 + exit 255 fi if ! ping -qc 1 "$HOSTNAME" > /dev/null then echo "The new hostname $HOSTNAME is not pingable. Make sure name resolution is configured" - exit -2 + exit 255 fi for svc in puppet pe-puppetserver pe-activemq mcollective pe-puppetdb pe-postgresql pe-console-services pe-nginx pe-orchestration-services pxp-agent; do