Showing with 150 additions and 66 deletions.
  1. +7 −5 .sync.yml
  2. +12 −1 CHANGELOG.md
  3. +32 −33 Gemfile
  4. +1 −1 Rakefile
  5. +3 −3 acceptance/Gemfile
  6. +1 −1 metadata.json
  7. +3 −3 spec/classes/puppet_agent_osfamily_debian_spec.rb
  8. +15 −2 task_spec/spec/acceptance/init_spec.rb
  9. +76 −17 tasks/install_shell.sh
12 changes: 7 additions & 5 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ Gemfile:
optional:
":development":
- gem: beaker
version: '~> 4.30'
version: '~> 5.0'
from_env: BEAKER_VERSION
- gem: beaker-abs
from_env: BEAKER_ABS_VERSION
version: '~> 0.9'
version: '~> 1.0'
- gem: beaker-docker
version: '~> 0.3'
- gem: beaker-pe
- gem: beaker-hostgenerator
from_env: BEAKER_HOSTGENERATOR_VERSION
- gem: beaker-rspec
from_env: BEAKER_RSPEC_VERSION
# Prevent beaker-puppet from being installed on Ruby > 3.1 until beaker-puppet supports newer Rubies (PA-6136)
- gem: beaker-puppet
from_env: BEAKER_PUPPET_VERSION
version: '~> 1.22'
version: '~> 3.0'
condition: Gem::Requirement.create('< 3.2.0').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
- gem: beaker-module_install_helper
- gem: beaker-puppet_install_helper
- gem: nokogiri
Expand Down Expand Up @@ -64,4 +65,5 @@ Rakefile:
extra_disabled_lint_checks:
- puppet_url_without_modules
requires:
- voxpupuli/acceptance/rake
- require: voxpupuli/acceptance/rake
conditional: Gem.loaded_specs.key? 'voxpupuli-acceptance'
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).

## [v4.19.0](https://github.com/puppetlabs/puppetlabs-puppet_agent/tree/v4.19.0) - 2024-03-06

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_agent/compare/v4.18.0...v4.19.0)

### Added

- [Fix #703] use 'type' instead of 'which' for increased portability [#704](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/704) ([zbentley](https://github.com/zbentley))
- support download with python3 urllib.request [#702](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/702) ([h0tw1r3](https://github.com/h0tw1r3))
- Add Debian 12 bookworm support [#698](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/698) ([h0tw1r3](https://github.com/h0tw1r3))
- support download with perl file::fetch [#697](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/697) ([h0tw1r3](https://github.com/h0tw1r3))

## [v4.18.0](https://github.com/puppetlabs/puppetlabs-puppet_agent/tree/v4.18.0) - 2024-01-10

[Full Changelog](https://github.com/puppetlabs/puppetlabs-puppet_agent/compare/v4.17.0...v4.18.0)
Expand Down Expand Up @@ -370,7 +381,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
- (MODULES-10238) Add Fedora 31 to puppet_agent module [#456](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/456) ([luchihoratiu](https://github.com/luchihoratiu))
- (MODULES-10067) enhance perl download check [#455](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/455) ([ciprianbadescu](https://github.com/ciprianbadescu))
- (maint) Merge release to master [#453](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/453) ([Dorin-Pleava](https://github.com/Dorin-Pleava))
- (MODULES-10055) fix linter-errors in puppetlabs/puppet_agent [#451](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/451) ([atarax](https://github.com/atarax))
- (MODULES-10055) fix linter-errors in puppetlabs/puppet_agent [#451](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/451) ([t-kaesser](https://github.com/t-kaesser))
- (maint) Updated metadata.json with support for Windows Server 2019 [#449](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/449) ([sootysec](https://github.com/sootysec))
- (MODULES-27043) Puppet agent upgrade for windows FIPS [#448](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/448) ([Dorin-Pleava](https://github.com/Dorin-Pleava))
- (MODULES-10052) parameterize WaitForExit timeout in puppet_agent install script [#436](https://github.com/puppetlabs/puppetlabs-puppet_agent/pull/436) ([lucaswyoung](https://github.com/lucaswyoung))
Expand Down
65 changes: 32 additions & 33 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,41 +14,40 @@ def location_for(place_or_version, fake_version = nil)
end

group :development do
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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 1.18', require: false
gem "metadata-json-lint", '~> 3.0', require: false
gem "puppetlabs_spec_helper", '~> 6.0', require: false
gem "rspec-puppet-facts", '~> 2.0', require: false
gem "codecov", '~> 0.2', require: false
gem "dependency_checker", '~> 1.0.0', require: false
gem "parallel_tests", '= 3.12.1', require: false
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.5', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '= 1.48.1', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "puppet-strings", '~> 4.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.30')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.9')
gem "beaker-docker", '~> 0.3', require: false
gem "beaker-pe", require: false
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 "json", '= 2.3.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.5.1', require: false if Gem::Requirement.create(['>= 3.0.0', '< 3.0.5']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.1', require: false if Gem::Requirement.create(['>= 3.1.0', '< 3.1.3']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.6.3', require: false if Gem::Requirement.create(['>= 3.2.0', '< 4.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "racc", '~> 1.4.0', require: false if Gem::Requirement.create(['>= 2.7.0', '< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false
gem "facterdb", '~> 1.18', require: false
gem "metadata-json-lint", '~> 3.0', require: false
gem "puppetlabs_spec_helper", '~> 6.0', require: false
gem "rspec-puppet-facts", '~> 2.0', require: false
gem "codecov", '~> 0.2', require: false
gem "dependency_checker", '~> 1.0.0', require: false
gem "parallel_tests", '= 3.12.1', require: false
gem "pry", '~> 0.10', require: false
gem "simplecov-console", '~> 0.5', require: false
gem "puppet-debugger", '~> 1.0', require: false
gem "rubocop", '= 1.48.1', require: false
gem "rubocop-performance", '= 1.16.0', require: false
gem "rubocop-rspec", '= 2.19.0', require: false
gem "puppet-strings", '~> 4.0', require: false
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 5.0')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 1.0')
gem "beaker-docker", '~> 0.3', require: false
gem "beaker-hostgenerator"
gem "beaker-rspec"
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 1.22')
gem "beaker-module_install_helper", require: false
gem "beaker-puppet_install_helper", require: false
gem "nokogiri", require: false
gem "bolt", '~> 3.0', require: false if ENV["GEM_BOLT"]
gem "beaker-task_helper", '~> 1.9', require: false if ENV["GEM_BOLT"]
gem "async", '~> 1.30', require: false
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 3.0') if Gem::Requirement.create('< 3.2.0').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "beaker-module_install_helper", require: false
gem "beaker-puppet_install_helper", require: false
gem "nokogiri", require: false
gem "bolt", '~> 3.0', require: false if ENV["GEM_BOLT"]
gem "beaker-task_helper", '~> 1.9', require: false if ENV["GEM_BOLT"]
gem "async", '~> 1.30', require: false
end
group :system_tests do
gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw]
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'github_changelog_generator/task' if Gem.loaded_specs.key? 'github_changelog_generator'
require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings'
require 'voxpupuli/acceptance/rake'
require 'voxpupuli/acceptance/rake' if Gem.loaded_specs.key? 'voxpupuli-acceptance'

def changelog_user
return unless Rake.application.top_level_tasks.include? "changelog"
Expand Down
6 changes: 3 additions & 3 deletions acceptance/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ end

gem "rake", "~> 12.3"

gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4')
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || 'https://github.com/voxpupuli/beaker-puppet#master')
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 5')
gem "beaker-puppet", *location_for(ENV['BEAKER_PUPPET_VERSION'] || '~> 3')

gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || '~> 0')
gem "beaker-vagrant", *location_for(ENV['BEAKER_VAGRANT_VERSION'] || '~> 0')
gem "beaker-vmpooler", *location_for(ENV['BEAKER_VMPOOLER_VERSION'] || '~> 1')
gem "beaker-hostgenerator", *location_for(ENV['BEAKER_HOSTGENERATOR_VERSION'] || '~> 2')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 1')
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "puppetlabs-puppet_agent",
"version": "4.18.0",
"version": "4.19.0",
"author": "puppetlabs",
"summary": "Upgrades All-In-One Puppet Agents",
"license": "Apache-2.0",
Expand Down
6 changes: 3 additions & 3 deletions spec/classes/puppet_agent_osfamily_debian_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
family: 'Debian',
name: 'Debian',
distro: {
codename: 'stretch',
codename: 'buster',
id: 'Debian',
},
release: {
full: '9.0',
major: '9',
full: '10.0',
major: '10',
},
},
puppet_master_server: 'master.example.vm',
Expand Down
17 changes: 15 additions & 2 deletions task_spec/spec/acceptance/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,19 @@ def log_output_errors(result)
puts logger.info(out)
end

# Added this method to simplify the 'case' condition
# used for target_platform, which will use latest puppet_agent
# in below mentioned test spec
def latest_platform_list
%r{
el-9-aarch64|
ubuntu-22\.04-aarch64|
amazon-2023|
osx-14|
debian-12
}x
end

it 'works with version and install tasks' do
# Specify the first released version for each target platform. When adding a new
# OS, you'll typically want to specify 'latest' to install from nightlies, since
Expand All @@ -56,7 +69,7 @@ def log_output_errors(result)
'7.18.0'
when %r{osx-13}
'7.26.0'
when %r{el-9-aarch64}, %r{ubuntu-22.04-aarch64}, %r{amazon-2023-x86_64}, %r{amazon-2023-aarch64}, %r{osx-14}
when latest_platform_list
'latest'
else
'7.18.0'
Expand All @@ -71,7 +84,7 @@ def log_output_errors(result)
# else
# end
case target_platform
when %r{el-9-aarch64}, %r{ubuntu-22.04-aarch64}, %r{amazon-2023-x86_64}, %r{amazon-2023-aarch64}, %r{osx-14}
when latest_platform_list
puppet_7_collection = 'puppet7-nightly'
puppet_8_collection = 'puppet8-nightly'
else
Expand Down
93 changes: 76 additions & 17 deletions tasks/install_shell.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,25 @@ assert_unmodified_apt_config() {
fi
}

# Check whether python3 and urllib.request are available
exists_python3_urllib() {
python3 -c 'import urllib.request' >/dev/null 2>&1
}

# Check whether perl and LWP::Simple module are installed
exists_perl() {
if perl -e 'use LWP::Simple;' >/dev/null 2>&1
then
exists_perl_lwp() {
if perl -e 'use LWP::Simple;' >/dev/null 2>&1 ; then
return 0
else
return 1
fi
return 1
}

# Check whether perl and File::Fetch module are installed
exists_perl_ff() {
if perl -e 'use File::Fetch;' >/dev/null 2>&1 ; then
return 0
fi
return 1
}

# Get command line arguments
Expand Down Expand Up @@ -133,7 +144,7 @@ fi
# Track to handle puppet5 to puppet6
if [ -f /opt/puppetlabs/puppet/VERSION ]; then
installed_version=`cat /opt/puppetlabs/puppet/VERSION`
elif which puppet >/dev/null 2>&1; then
elif type -p puppet >/dev/null; then
installed_version=`puppet --version`
else
installed_version=uninstalled
Expand Down Expand Up @@ -421,9 +432,28 @@ do_fetch() {
return 0
}

# do_perl URL FILENAME
do_perl() {
info "Trying perl..."
do_python3_urllib() {
info "Trying python3 (urllib.request)..."
run_cmd "python3 -c 'import urllib.request ; urllib.request.urlretrieve(\"$1\", \"$2\")'" 2>$tmp_stderr
rc=$?

# check for 404
if grep "404: Not Found" $tmp_stderr 2>&1 >/dev/null ; then
critical "ERROR 404"
unable_to_retrieve_package
fi

if test $rc -eq 0 && test -s "$2" ; then
return 0
fi

capture_tmp_stderr "perl"
return 1
}

# do_perl_lwp URL FILENAME
do_perl_lwp() {
info "Trying perl (LWP::Simple)..."
run_cmd "perl -e 'use LWP::Simple; getprint(\$ARGV[0]);' '$1' > '$2' 2>$tmp_stderr"
rc=$?

Expand All @@ -434,13 +464,33 @@ do_perl() {
unable_to_retrieve_package
fi

# check for bad return status or empty output
if test $rc -ne 0 || test ! -s "$2"; then
capture_tmp_stderr "perl"
return 1
if test $rc -eq 0 && test -s "$2" ; then
return 0
fi

return 0
capture_tmp_stderr "perl"
return 1
}

# do_perl_ff URL FILENAME
do_perl_ff() {
info "Trying perl (File::Fetch)..."
run_cmd "perl -e 'use File::Fetch; use File::Copy; my \$ff = File::Fetch->new(uri => \$ARGV[0]); my \$outfile = \$ff->fetch() or die \$ff->server; copy(\$outfile, \$ARGV[1]) or die \"copy failed: \$!\"; unlink(\$outfile) or die \"delete failed: \$!\";' '$1' '$2' 2>>$tmp_stderr"
rc=$?

# check for 404
grep "HTTP response: 404" $tmp_stderr 2>&1 >/dev/null
if test $? -eq 0 ; then
critical "ERROR 404"
unable_to_retrieve_package
fi

if test $rc -eq 0 && test -s "$2" ; then
return 0
fi

capture_tmp_stderr "perl"
return 1
}

# do_download URL FILENAME
Expand All @@ -463,11 +513,19 @@ do_download() {
do_fetch $1 $2 && return 0
fi

if exists_perl; then
do_perl $1 $2 && return 0
if exists_perl_lwp; then
do_perl_lwp $1 $2 && return 0
fi

if exists_perl_ff; then
do_perl_ff $1 $2 && return 0
fi

if exists_python3_urllib; then
do_python3_urllib $1 $2 && return 0
fi

critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple is found"
critical "Cannot download package as none of wget/curl/fetch/perl-LWP-Simple/perl-File-Fetch/python3 is found"
unable_to_retrieve_package
}

Expand Down Expand Up @@ -621,6 +679,7 @@ case $platform in
case $major_version in
"10") deb_codename="buster";;
"11") deb_codename="bullseye";;
"12") deb_codename="bookworm";;
esac
filetype="deb"
filename="${collection}-release-${deb_codename}.deb"
Expand Down