From 94c529b3a14f83e35b297de6a2503a4e0353cad9 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 11 Mar 2024 13:05:14 +0000 Subject: [PATCH 01/25] Release prep v9.5.0 --- CHANGELOG.md | 52 +++++++++++++++++++++++--------------- REFERENCE.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++ metadata.json | 2 +- 3 files changed, 103 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7178301e3..bcb50c1a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,23 @@ 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). -## [v9.4.1](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.4.1) - 2023-11-08 +## [v9.5.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.5.0) - 2024-03-11 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.4.1...v9.5.0) + +### Added + +- Add function stdlib::sort_by [#1384](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1384) ([XMol](https://github.com/XMol)) + +### Fixed + +- (#1389) - pw_hash with bcrypt not working on puppet master [#1410](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1410) ([TuningYourCode](https://github.com/TuningYourCode)) + +### Other + +- Deprecate `time` function [#1417](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1417) ([alexjfisher](https://github.com/alexjfisher)) + +## [v9.4.1](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.4.1) - 2023-11-09 [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.4.0...v9.4.1) @@ -21,10 +37,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Modernise `fqdn_rotate` function [#1341](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1341) ([alexjfisher](https://github.com/alexjfisher)) -### Other - -- Remove unused parser deprecation function [#1392](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1392) ([ekohl](https://github.com/ekohl)) - ## [v9.3.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.3.0) - 2023-08-01 [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.2.0...v9.3.0) @@ -68,11 +80,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v8.6.0...v9.0.0) -### Added - -- Namespace Puppet 4.x functions [#1356](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1356) ([smortex](https://github.com/smortex)) -- Add a function to update / regenerate deprecated shims [#1349](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1349) ([smortex](https://github.com/smortex)) - ### Changed - Deprecate the `validate_legacy()` function [#1353](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1353) ([smortex](https://github.com/smortex)) - Remove deprecated functions [#1352](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1352) ([smortex](https://github.com/smortex)) @@ -108,6 +115,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a - Remove deprecated type and type3x functions [#1309](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1309) ([MartyEwings](https://github.com/MartyEwings)) - (CONT-801) Puppet 8 support / Drop Puppet 6 support [#1307](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1307) ([LukasAud](https://github.com/LukasAud)) +### Added + +- Namespace Puppet 4.x functions [#1356](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1356) ([smortex](https://github.com/smortex)) +- Add a function to update / regenerate deprecated shims [#1349](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1349) ([smortex](https://github.com/smortex)) + ### Fixed - Remove deprecated File.exists? [#1357](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1357) ([ekohl](https://github.com/ekohl)) @@ -226,18 +238,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v7.1.0...v8.0.0) +### Changed +- Flip installed and present in Function ensure_packages [#1196](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1196) ([cocker-cc](https://github.com/cocker-cc)) + ### Added - New function to_python() / to_ruby() [#1200](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1200) ([smortex](https://github.com/smortex)) - pdksync - (IAC-1709) - Add Support for Debian 11 [#1199](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1199) ([david22swan](https://github.com/david22swan)) - Stdlib::Http::Method: Add new type for http methods [#1192](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1192) ([b4ldr](https://github.com/b4ldr)) -### Changed -- Flip installed and present in Function ensure_packages [#1196](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1196) ([cocker-cc](https://github.com/cocker-cc)) - ### Fixed -- (MODULES-11099) Make merge parameter data types actually backwards compatible [#1191](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1191) ([SimonPe](https://github.com/SimonPe)) +- (MODULES-11099) Make merge parameter data types actually backwards compatible [#1191](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1191) ([LadyNamedLaura](https://github.com/LadyNamedLaura)) ## [v7.1.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v7.1.0) - 2021-05-17 @@ -259,13 +271,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.6.0...v7.0.0) +### Changed +- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#1164](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1164) ([carabasdaniel](https://github.com/carabasdaniel)) + ### Added - Stdlib::Email type [#1160](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1160) ([b4ldr](https://github.com/b4ldr)) -### Changed -- pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#1164](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1164) ([carabasdaniel](https://github.com/carabasdaniel)) - ### Fixed - (bugfix) Setting stricter email validation [#1163](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1163) ([pmcmaw](https://github.com/pmcmaw)) @@ -367,14 +379,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.2.0...v6.0.0) +### Changed +- pdksync - (MODULES-8444) - Raise lower Puppet bound [#1011](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1011) ([david22swan](https://github.com/david22swan)) + ### Added - (MODULES-8760) Add iterative feature to merge() function [#1008](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1008) ([hlindberg](https://github.com/hlindberg)) - Add a stdlib::ip_in_range() function [#1003](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1003) ([iglov](https://github.com/iglov)) -### Changed -- pdksync - (MODULES-8444) - Raise lower Puppet bound [#1011](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1011) ([david22swan](https://github.com/david22swan)) - ## [5.2.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/5.2.0) - 2019-01-18 [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.1.0...5.2.0) diff --git a/REFERENCE.md b/REFERENCE.md index 5e97d1ac8..8e6621420 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -139,6 +139,7 @@ Puppet structure * [`stdlib::seeded_rand_string`](#stdlib--seeded_rand_string): Generates a consistent random string of specific length based on provided seed. * [`stdlib::sha256`](#stdlib--sha256): Run a SHA256 calculation against a given value. * [`stdlib::shell_escape`](#stdlib--shell_escape): Escapes a string so that it can be safely used in a Bourne shell command line. +* [`stdlib::sort_by`](#stdlib--sort_by): Sort an Array, Hash or String by mapping values through a given block. * [`stdlib::start_with`](#stdlib--start_with): Returns true if str starts with one of the prefixes given. Each of the prefixes should be a String. * [`stdlib::str2resource`](#stdlib--str2resource): This converts a string to a puppet resource. * [`stdlib::time`](#stdlib--time): This function is deprecated. It implements the functionality of the original non-namespaced stdlib `time` function. @@ -4003,6 +4004,75 @@ Data type: `Any` The string to escape +### `stdlib::sort_by` + +Type: Ruby 4.x API + +Sort an Array, Hash or String by mapping values through a given block. + +#### Examples + +##### Sort local devices according to their used space. + +```puppet +$facts['mountpoints'].stdlib::sort_by |$m| { $m.dig(1, 'used_bytes') } +``` + +#### `stdlib::sort_by(Array $ary, Callable[1,1] &$block)` + +The stdlib::sort_by function. + +Returns: `Array` Returns an ordered copy of ary. + +##### `ary` + +Data type: `Array` + +The Array to sort. + +##### `&block` + +Data type: `Callable[1,1]` + +The block for transforming elements of ary. + +#### `stdlib::sort_by(String $str, Callable[1,1] &$block)` + +The stdlib::sort_by function. + +Returns: `String` Returns an ordered copy of str. + +##### `str` + +Data type: `String` + +The String to sort. + +##### `&block` + +Data type: `Callable[1,1]` + +The block for transforming elements of str. + +#### `stdlib::sort_by(Hash $hsh, Variant[Callable[1,1], Callable[2,2]] &$block)` + +The stdlib::sort_by function. + +Returns: `Hash` Returns an ordered copy of hsh. + +##### `hsh` + +Data type: `Hash` + +The Hash to sort. + +##### `&block` + +Data type: `Variant[Callable[1,1], Callable[2,2]]` + +The block for transforming elements of hsh. +The block may have arity of one or two. + ### `stdlib::start_with` Type: Ruby 4.x API diff --git a/metadata.json b/metadata.json index ad43452cf..1befd5b66 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "9.4.1", + "version": "9.5.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", From c4876b8890b030a5e2cece7c5bba0bc2e25a2f86 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Tue, 26 Mar 2024 09:53:52 +0100 Subject: [PATCH 02/25] Allow usage of file templates with stdlib::manage This one only covers epp templates. --- manifests/manage.pp | 45 +++++++++++++++++++++++++++++-------- spec/classes/manage_spec.rb | 4 ++++ templates/manage_spec.epp | 1 + 3 files changed, 41 insertions(+), 9 deletions(-) create mode 100644 templates/manage_spec.epp diff --git a/manifests/manage.pp b/manifests/manage.pp index 1324187a7..508e91e49 100644 --- a/manifests/manage.pp +++ b/manifests/manage.pp @@ -14,17 +14,21 @@ # # @example # class { 'stdlib::manage': -# 'create_resources' => { -# 'file' => { +# 'create_resources' => { +# 'file' => { # '/etc/motd.d/hello' => { -# 'content' => 'I say Hi', -# 'notify' => 'Service[sshd]', +# 'content' => 'I say Hi', +# 'notify' => 'Service[sshd]', +# }, +# '/etc/motd' => { +# 'ensure' => 'file', +# 'template' => 'profile/motd.epp', # } # }, -# 'package' => { -# 'example' => { -# 'ensure' => 'installed', -# 'subscribe' => ['Service[sshd]', 'Exec[something]'], +# 'package' => { +# 'example' => { +# 'ensure' => 'installed', +# 'subscribe' => ['Service[sshd]', 'Exec[something]'], # } # } # } @@ -35,6 +39,9 @@ # '/etc/motd.d/hello': # content: I say Hi # notify: 'Service[sshd]' +# '/etc/motd': +# ensure: 'file' +# template: 'profile/motd.epp' # package: # example: # ensure: installed @@ -46,7 +53,27 @@ ) { $create_resources.each |$type, $resources| { $resources.each |$title, $attributes| { - create_resources($type, { $title => $attributes }) + case $type { + 'file': { + if 'template' in $attributes and 'content' in $attributes { + fail("You can not set content and template fir file ${title}") + } + if 'template' in $attributes { + $content = epp($attributes['template']) + } elsif 'content' in $attributes { + $content = $attributes['content'] + } else { + $content = undef + } + file { $title: + * => $attributes - 'template' - 'content', + content => $content, + } + } + default: { + create_resources($type, { $title => $attributes }) + } + } } } } diff --git a/spec/classes/manage_spec.rb b/spec/classes/manage_spec.rb index a34fc7296..d6958423f 100644 --- a/spec/classes/manage_spec.rb +++ b/spec/classes/manage_spec.rb @@ -25,6 +25,9 @@ '/etc/motd.d/hello' => { 'content' => 'I say Hi', 'notify' => 'Service[sshd]' + }, + '/etc/motd' => { + 'template' => 'stdlib/manage_spec.epp' } }, 'package' => { @@ -39,6 +42,7 @@ it { is_expected.to compile } it { is_expected.to contain_file('/etc/motd.d/hello').with_content('I say Hi').with_notify('Service[sshd]') } + it { is_expected.to contain_file('/etc/motd').with_content(%r{I am a template}) } it { is_expected.to contain_package('example').with_ensure('installed').that_subscribes_to(['Service[sshd]', 'File[/etc/motd.d]']) } end end diff --git a/templates/manage_spec.epp b/templates/manage_spec.epp new file mode 100644 index 000000000..9258d279e --- /dev/null +++ b/templates/manage_spec.epp @@ -0,0 +1 @@ +I am a template From 3031f97c0f0f96e773f4c3837c351938800b7e5d Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Tue, 26 Mar 2024 12:57:07 +0100 Subject: [PATCH 03/25] replace template with epp function stub fix misspelling in fail function --- manifests/manage.pp | 2 +- spec/classes/manage_spec.rb | 3 +++ templates/manage_spec.epp | 1 - 3 files changed, 4 insertions(+), 2 deletions(-) delete mode 100644 templates/manage_spec.epp diff --git a/manifests/manage.pp b/manifests/manage.pp index 508e91e49..eeea09f60 100644 --- a/manifests/manage.pp +++ b/manifests/manage.pp @@ -56,7 +56,7 @@ case $type { 'file': { if 'template' in $attributes and 'content' in $attributes { - fail("You can not set content and template fir file ${title}") + fail("You can not set 'content' and 'template' for file ${title}") } if 'template' in $attributes { $content = epp($attributes['template']) diff --git a/spec/classes/manage_spec.rb b/spec/classes/manage_spec.rb index d6958423f..75168eb8d 100644 --- a/spec/classes/manage_spec.rb +++ b/spec/classes/manage_spec.rb @@ -39,6 +39,9 @@ } } end + Puppet::Functions.create_function(:'epp') do + return 'I am a template' + end it { is_expected.to compile } it { is_expected.to contain_file('/etc/motd.d/hello').with_content('I say Hi').with_notify('Service[sshd]') } diff --git a/templates/manage_spec.epp b/templates/manage_spec.epp deleted file mode 100644 index 9258d279e..000000000 --- a/templates/manage_spec.epp +++ /dev/null @@ -1 +0,0 @@ -I am a template From 9028ad38213dee89910e9fc1091f4e4053272ad4 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Tue, 26 Mar 2024 13:02:53 +0100 Subject: [PATCH 04/25] rubocop --- spec/classes/manage_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/classes/manage_spec.rb b/spec/classes/manage_spec.rb index 75168eb8d..b1422266f 100644 --- a/spec/classes/manage_spec.rb +++ b/spec/classes/manage_spec.rb @@ -39,7 +39,8 @@ } } end - Puppet::Functions.create_function(:'epp') do + + Puppet::Functions.create_function(:epp) do return 'I am a template' end From 6b9805486778f3bed58be110caa1196064ffb8b9 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 27 Mar 2024 08:50:07 +0100 Subject: [PATCH 05/25] allow erb and epp templates --- manifests/manage.pp | 41 +++++++++++++++++++++++++++++++------ spec/classes/manage_spec.rb | 17 ++++++++++++--- 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/manifests/manage.pp b/manifests/manage.pp index eeea09f60..be898e4e6 100644 --- a/manifests/manage.pp +++ b/manifests/manage.pp @@ -41,7 +41,13 @@ # notify: 'Service[sshd]' # '/etc/motd': # ensure: 'file' -# template: 'profile/motd.epp' +# epp: +# template: 'profile/motd.epp' +# context: {} +# '/etc/information': +# ensure: 'file' +# erb: +# template: 'profile/information.erb' # package: # example: # ensure: installed @@ -55,18 +61,41 @@ $resources.each |$title, $attributes| { case $type { 'file': { - if 'template' in $attributes and 'content' in $attributes { - fail("You can not set 'content' and 'template' for file ${title}") + # sanity checks + # epp, erb and content are exclusive + if 'epp' in $attributes and 'content' in $attributes { + fail("You can not set 'epp' and 'content' for file ${title}") + } + if 'erb' in $attributes and 'content' in $attributes { + fail("You can not set 'erb' and 'content' for file ${title}") + } + if 'erb' in $attributes and 'epp' in $attributes { + fail("You can not set 'erb' and 'epp' for file ${title}") } - if 'template' in $attributes { - $content = epp($attributes['template']) + + if 'epp' in $attributes { + if 'template' in $attributes['epp'] { + if 'context' in $attributes['epp'] { + $content = epp($attributes['epp']['template'], $attributes['epp']['context']) + } else { + $content = epp($attributes['epp']['template']) + } + } else { + fail("No template configured for epp for file ${title}") + } + } elsif 'erb' in $attributes { + if 'template' in $attributes['erb'] { + $content = template($attributes['erb']['template']) + } else { + fail("No template configured for erb for file ${title}") + } } elsif 'content' in $attributes { $content = $attributes['content'] } else { $content = undef } file { $title: - * => $attributes - 'template' - 'content', + * => $attributes - 'erb' - 'epp' - 'content', content => $content, } } diff --git a/spec/classes/manage_spec.rb b/spec/classes/manage_spec.rb index b1422266f..ce78ec2f0 100644 --- a/spec/classes/manage_spec.rb +++ b/spec/classes/manage_spec.rb @@ -27,7 +27,14 @@ 'notify' => 'Service[sshd]' }, '/etc/motd' => { - 'template' => 'stdlib/manage_spec.epp' + 'epp' => { + 'template' => 'profile/motd.epp' + } + }, + '/etc/information' => { + 'erb' => { + 'template' => 'profile/information.erb' + } } }, 'package' => { @@ -41,12 +48,16 @@ end Puppet::Functions.create_function(:epp) do - return 'I am a template' + return 'I am an epp template' + end + Puppet::Functions.create_function(:template) do + return 'I am an erb template' end it { is_expected.to compile } it { is_expected.to contain_file('/etc/motd.d/hello').with_content('I say Hi').with_notify('Service[sshd]') } - it { is_expected.to contain_file('/etc/motd').with_content(%r{I am a template}) } + it { is_expected.to contain_file('/etc/motd').with_content(%r{I am an epp template}) } + it { is_expected.to contain_file('/etc/information').with_content(%r{I am an erb template}) } it { is_expected.to contain_package('example').with_ensure('installed').that_subscribes_to(['Service[sshd]', 'File[/etc/motd.d]']) } end end From bd6f29f8046c22c224cd2d57f87aa423ad0cc143 Mon Sep 17 00:00:00 2001 From: Martin Alfke Date: Wed, 27 Mar 2024 08:55:47 +0100 Subject: [PATCH 06/25] update puppet strings documentation --- manifests/manage.pp | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/manifests/manage.pp b/manifests/manage.pp index be898e4e6..82c39bc8d 100644 --- a/manifests/manage.pp +++ b/manifests/manage.pp @@ -10,28 +10,38 @@ # # @param create_resources # A hash of resources to create -# NOTE: functions, such as `template` or `epp`, are not evaluated. +# NOTE: functions, such as `template` or `epp`, are not directly evaluated +# but processed as Puppet code based on epp and erb hash keys. # # @example # class { 'stdlib::manage': -# 'create_resources' => { -# 'file' => { -# '/etc/motd.d/hello' => { -# 'content' => 'I say Hi', -# 'notify' => 'Service[sshd]', -# }, -# '/etc/motd' => { -# 'ensure' => 'file', -# 'template' => 'profile/motd.epp', +# 'create_resources' => { +# 'file' => { +# '/etc/motd.d/hello' => { +# 'content' => 'I say Hi', +# 'notify' => 'Service[sshd]', +# }, +# '/etc/motd' => { +# 'ensure' => 'file', +# 'epp' => { +# 'template' => 'profile/motd.epp', # } # }, -# 'package' => { -# 'example' => { -# 'ensure' => 'installed', -# 'subscribe' => ['Service[sshd]', 'Exec[something]'], +# '/etc/information' => { +# 'ensure' => 'file', +# 'erb' => { +# 'template' => 'profile/informaiton.erb', # } # } +# }, +# 'package' => { +# 'example' => { +# 'ensure' => 'installed', +# 'subscribe' => ['Service[sshd]', 'Exec[something]'], +# } # } +# } +# } # # @example # stdlib::manage::create_resources: From 1e507bb0e1b735afc42d92837cf8ce8e137a2672 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 2 Apr 2024 21:09:40 +0530 Subject: [PATCH 07/25] Fix mend to run on cron --- .github/workflows/mend.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml index b4100a5af..8b5b40184 100644 --- a/.github/workflows/mend.yml +++ b/.github/workflows/mend.yml @@ -1,9 +1,10 @@ name: "mend" on: - pull_request: - branches: - - "main" + pull_request_target: + types: + - opened + - synchronize schedule: - cron: "0 0 * * *" workflow_dispatch: From d4a95fd0b9136e1e1195415f77fa8445aff0cca8 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 3 Apr 2024 08:28:49 +0000 Subject: [PATCH 08/25] Release prep v9.6.0 --- CHANGELOG.md | 8 ++++++++ REFERENCE.md | 43 +++++++++++++++++++++++++++++++++---------- metadata.json | 2 +- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bcb50c1a7..71b2e8ac1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ 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). +## [v9.6.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.6.0) - 2024-04-03 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.5.0...v9.6.0) + +### Added + +- Allow usage of file templates with stdlib::manage [#1422](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1422) ([tuxmea](https://github.com/tuxmea)) + ## [v9.5.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.5.0) - 2024-03-11 [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.4.1...v9.5.0) diff --git a/REFERENCE.md b/REFERENCE.md index 8e6621420..63169ab67 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -266,20 +266,33 @@ and `subscribe`. ```puppet class { 'stdlib::manage': - 'create_resources' => { - 'file' => { - '/etc/motd.d/hello' => { - 'content' => 'I say Hi', - 'notify' => 'Service[sshd]', + 'create_resources' => { + 'file' => { + '/etc/motd.d/hello' => { + 'content' => 'I say Hi', + 'notify' => 'Service[sshd]', + }, + '/etc/motd' => { + 'ensure' => 'file', + 'epp' => { + 'template' => 'profile/motd.epp', } }, - 'package' => { - 'example' => { - 'ensure' => 'installed', - 'subscribe' => ['Service[sshd]', 'Exec[something]'], + '/etc/information' => { + 'ensure' => 'file', + 'erb' => { + 'template' => 'profile/informaiton.erb', } } + }, + 'package' => { + 'example' => { + 'ensure' => 'installed', + 'subscribe' => ['Service[sshd]', 'Exec[something]'], + } } + } +} ``` ##### @@ -290,6 +303,15 @@ stdlib::manage::create_resources: '/etc/motd.d/hello': content: I say Hi notify: 'Service[sshd]' + '/etc/motd': + ensure: 'file' + epp: + template: 'profile/motd.epp' + context: {} + '/etc/information': + ensure: 'file' + erb: + template: 'profile/information.erb' package: example: ensure: installed @@ -309,7 +331,8 @@ The following parameters are available in the `stdlib::manage` class: Data type: `Hash[String, Hash]` A hash of resources to create -NOTE: functions, such as `template` or `epp`, are not evaluated. +NOTE: functions, such as `template` or `epp`, are not directly evaluated + but processed as Puppet code based on epp and erb hash keys. Default value: `{}` diff --git a/metadata.json b/metadata.json index 1befd5b66..ce7b104f0 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "9.5.0", + "version": "9.6.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", From bd0a6e87d86e188321650eca9ccc0dfd8b69c6f2 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 1 May 2024 19:55:55 -0500 Subject: [PATCH 09/25] add support for AmazonLinux 2 and 2023 --- metadata.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/metadata.json b/metadata.json index ce7b104f0..4f8e476f3 100644 --- a/metadata.json +++ b/metadata.json @@ -95,6 +95,13 @@ "operatingsystemrelease": [ "8" ] + }, + { + "operatingsystem": "AmazonLinux", + "operatingsystemrelease": [ + "2", + "2023" + ] } ], "requirements": [ From 6887c4a657b95179bfb6ee95db922a594a1c45f2 Mon Sep 17 00:00:00 2001 From: Jeffrey Clark Date: Wed, 1 May 2024 19:57:17 -0500 Subject: [PATCH 10/25] remove puppet_agent fixture version pinned ref best practice --- .fixtures.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.fixtures.yml b/.fixtures.yml index cf4ff2d7b..b25e8c459 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,9 +1,7 @@ fixtures: repositories: facts: 'https://github.com/puppetlabs/puppetlabs-facts.git' - puppet_agent: - repo: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' - ref: v4.13.0 + puppet_agent: 'https://github.com/puppetlabs/puppetlabs-puppet_agent.git' provision: 'https://github.com/puppetlabs/provision.git' symlinks: stdlib: "#{source_dir}" From dfed386b41268324f9e57b4857191f257b936407 Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 21 May 2024 21:21:40 +0530 Subject: [PATCH 11/25] ITHELP-87329 : replace pull_request_target with pull_request --- .github/workflows/mend.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/mend.yml b/.github/workflows/mend.yml index 8b5b40184..b4100a5af 100644 --- a/.github/workflows/mend.yml +++ b/.github/workflows/mend.yml @@ -1,10 +1,9 @@ name: "mend" on: - pull_request_target: - types: - - opened - - synchronize + pull_request: + branches: + - "main" schedule: - cron: "0 0 * * *" workflow_dispatch: From c504c51e69610b3501d43aa151997a8d38c8037f Mon Sep 17 00:00:00 2001 From: Malik Parvez <84777619+malikparvez@users.noreply.github.com> Date: Tue, 4 Jun 2024 13:58:43 +0530 Subject: [PATCH 12/25] ITHELP-87329 : replace pull_request_target with pull_request --- .github/workflows/labeller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index ee149bf52..0d4870d70 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -6,7 +6,7 @@ on: - opened - labeled - unlabeled - pull_request_target: + pull_request: types: - opened - labeled From 12693e07ae12012a350cc170a52f228488209296 Mon Sep 17 00:00:00 2001 From: Ben Ford Date: Wed, 12 Jun 2024 13:09:40 -0700 Subject: [PATCH 13/25] Revert "pdksync - (ITHELP-87329) - replace pull_request_target with pull_request" --- .github/workflows/labeller.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml index 0d4870d70..ee149bf52 100644 --- a/.github/workflows/labeller.yml +++ b/.github/workflows/labeller.yml @@ -6,7 +6,7 @@ on: - opened - labeled - unlabeled - pull_request: + pull_request_target: types: - opened - labeled From c50bc78c79e3f43719baa7ef5817c70880779a78 Mon Sep 17 00:00:00 2001 From: rajat-puppet Date: Mon, 22 Jul 2024 17:31:20 +0530 Subject: [PATCH 14/25] Remove labeller.yml --- .github/workflows/labeller.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .github/workflows/labeller.yml diff --git a/.github/workflows/labeller.yml b/.github/workflows/labeller.yml deleted file mode 100644 index ee149bf52..000000000 --- a/.github/workflows/labeller.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Labeller - -on: - issues: - types: - - opened - - labeled - - unlabeled - pull_request_target: - types: - - opened - - labeled - - unlabeled - -jobs: - label: - runs-on: ubuntu-latest - steps: - - - uses: puppetlabs/community-labeller@v1.0.1 - name: Label issues or pull requests - with: - label_name: community - label_color: '5319e7' - org_membership: puppetlabs - fail_if_member: 'true' - token: ${{ secrets.IAC_COMMUNITY_LABELER }} From dfbf7738ca684967bd547f1cf1cb37adc8de9469 Mon Sep 17 00:00:00 2001 From: skyamgarp <130442619+skyamgarp@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:12:41 +0530 Subject: [PATCH 15/25] (CAT-2101) Add support for Debian-12 --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 4f8e476f3..7563572e0 100644 --- a/metadata.json +++ b/metadata.json @@ -49,7 +49,8 @@ "operatingsystem": "Debian", "operatingsystemrelease": [ "10", - "11" + "11", + "12" ] }, { From 29e6cb874a9f75661814782bd7b2c63f10140652 Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Mon, 4 Nov 2024 19:44:34 +0530 Subject: [PATCH 16/25] (CAT-2119) Add Ubuntu 24.04 support --- metadata.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 7563572e0..8e671eb97 100644 --- a/metadata.json +++ b/metadata.json @@ -58,7 +58,8 @@ "operatingsystemrelease": [ "18.04", "20.04", - "22.04" + "22.04", + "24.04" ] }, { From e2cf4e907fe773c5a8ee67e1b975f94ae8fd2b0f Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Tue, 5 Nov 2024 10:30:54 +0530 Subject: [PATCH 17/25] pdksync - (PF-3525) - pdk update for module --- .github/workflows/release.yml | 2 +- .gitignore | 7 +++++++ .pdkignore | 7 +++++++ .rubocop.yml | 8 +++++++- .vscode/extensions.json | 2 +- Gemfile | 28 ++++++++++++++-------------- metadata.json | 4 ++-- spec/spec_helper.rb | 5 +++-- 8 files changed, 42 insertions(+), 21 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0b7b8a05d..4b3b80fc8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: "Publish module" on: workflow_dispatch: - + jobs: release: uses: "puppetlabs/cat-github-actions/.github/workflows/module_release.yml@main" diff --git a/.gitignore b/.gitignore index 3f1551212..2803e566b 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,3 +27,9 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log diff --git a/.pdkignore b/.pdkignore index 862847a72..84684be63 100644 --- a/.pdkignore +++ b/.pdkignore @@ -19,6 +19,7 @@ /spec/fixtures/modules/* /tmp/ /vendor/ +/.vendor/ /convert_report.txt /update_report.txt .DS_Store @@ -26,6 +27,12 @@ .envrc /inventory.yaml /spec/fixtures/litmus_inventory.yaml +.resource_types +.modules +.task_cache.json +.plan_cache.json +.rerun.json +bolt-debug.log /.fixtures.yml /Gemfile /.gitattributes diff --git a/.rubocop.yml b/.rubocop.yml index 7a66e0833..439ea84ee 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.7' + TargetRubyVersion: '2.6' Include: - "**/*.rb" Exclude: @@ -529,6 +529,8 @@ Lint/DuplicateBranch: Enabled: false Lint/DuplicateMagicComment: Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false Lint/DuplicateRegexpCharacterClassElement: Enabled: false Lint/EmptyBlock: @@ -645,6 +647,8 @@ Style/ComparableClamp: Enabled: false Style/ConcatArrayLiterals: Enabled: false +Style/DataInheritance: + Enabled: false Style/DirEmpty: Enabled: false Style/DocumentDynamicEvalDefinition: @@ -713,6 +717,8 @@ Style/RedundantHeredocDelimiterQuotes: Enabled: false Style/RedundantInitialize: Enabled: false +Style/RedundantLineContinuation: + Enabled: false Style/RedundantSelfAssignmentBranch: Enabled: false Style/RedundantStringEscape: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 2f1e4f73a..6da8d472f 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,6 @@ { "recommendations": [ "puppet.puppet-vscode", - "rebornix.Ruby" + "Shopify.ruby-lsp" ] } diff --git a/Gemfile b/Gemfile index ca0e773ec..8e9f845e1 100644 --- a/Gemfile +++ b/Gemfile @@ -20,30 +20,30 @@ group :development do 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 "deep_merge", '~> 1.2.2', require: false 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 "facterdb", '~> 2.1', require: false + gem "metadata-json-lint", '~> 4.0', require: false + gem "rspec-puppet-facts", '~> 4.0', 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 "simplecov-console", '~> 0.9', require: false gem "puppet-debugger", '~> 1.0', require: false - gem "rubocop", '= 1.48.1', require: false + gem "rubocop", '~> 1.50.0', 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 "rexml", '>= 3.0.0', '< 3.2.7', require: false end -group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] - gem "serverspec", '~> 2.41', require: false -end -group :release_prep do +group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 6.0', require: false + gem "puppetlabs_spec_helper", '~> 7.0', require: false +end +group :system_tests do + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] + gem "serverspec", '~> 2.41', require: false end puppet_version = ENV['PUPPET_GEM_VERSION'] diff --git a/metadata.json b/metadata.json index 7563572e0..d86206e01 100644 --- a/metadata.json +++ b/metadata.json @@ -112,7 +112,7 @@ } ], "description": "Standard Library for Puppet Modules", - "pdk-version": "3.0.0", + "pdk-version": "3.2.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "heads/main-0-g79a2f93" + "template-ref": "tags/3.2.0.4-0-g5d17ec1" } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6820cebee..ae7c1f681 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -25,7 +25,8 @@ next unless File.exist?(f) && File.readable?(f) && File.size?(f) begin - default_facts.merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) + require 'deep_merge' + default_facts.deep_merge!(YAML.safe_load(File.read(f), permitted_classes: [], permitted_symbols: [], aliases: true)) rescue StandardError => e RSpec.configuration.reporter.message "WARNING: Unable to load #{f}: #{e}" end @@ -33,7 +34,7 @@ # read default_facts and merge them over what is provided by facterdb default_facts.each do |fact, value| - add_custom_fact fact, value + add_custom_fact fact, value, merge_facts: true end RSpec.configure do |c| From 651a778d2294a00b754a3197de7da536f4fc458a Mon Sep 17 00:00:00 2001 From: Amit Karsale Date: Fri, 29 Nov 2024 15:36:24 +0530 Subject: [PATCH 18/25] (CAT-2180) Upgrade rexml to address CVE-2024-49761 --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 8e9f845e1..2d8e1608b 100644 --- a/Gemfile +++ b/Gemfile @@ -34,7 +34,7 @@ group :development do gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.0.0', '< 3.2.7', require: false + gem "rexml", '>= 3.3.9', require: false end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false From 9f9923f71583b0b7e3ca40202b7cb4d3ace564a7 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 17 Dec 2024 06:28:06 +0000 Subject: [PATCH 19/25] Release prep v9.7.0 --- CHANGELOG.md | 18 ++++++++++++++++++ metadata.json | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71b2e8ac1..6f650b7a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,20 @@ 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). +## [v9.7.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.7.0) - 2024-12-17 + +[Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.6.0...v9.7.0) + +### Added + +- (CAT-2119) Add Ubuntu 24.04 support [#1440](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1440) ([shubhamshinde360](https://github.com/shubhamshinde360)) +- (CAT-2101) Add support for Debian-12 [#1439](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1439) ([skyamgarp](https://github.com/skyamgarp)) +- Support for Amazon linux 2 and 2023 [#1427](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1427) ([h0tw1r3](https://github.com/h0tw1r3)) + +### Fixed + +- (CAT-2180) Upgrade rexml to address CVE-2024-49761 [#1443](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1443) ([amitkarsale](https://github.com/amitkarsale)) + ## [v9.6.0](https://github.com/puppetlabs/puppetlabs-stdlib/tree/v9.6.0) - 2024-04-03 [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v9.5.0...v9.6.0) @@ -89,6 +103,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v8.6.0...v9.0.0) ### Changed + - Deprecate the `validate_legacy()` function [#1353](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1353) ([smortex](https://github.com/smortex)) - Remove deprecated functions [#1352](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1352) ([smortex](https://github.com/smortex)) - Rewrite validate_email_address() as a Puppet 4.x function [#1350](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1350) ([smortex](https://github.com/smortex)) @@ -247,6 +262,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v7.1.0...v8.0.0) ### Changed + - Flip installed and present in Function ensure_packages [#1196](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1196) ([cocker-cc](https://github.com/cocker-cc)) ### Added @@ -280,6 +296,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/v6.6.0...v7.0.0) ### Changed + - pdksync - Remove Puppet 5 from testing and bump minimal version to 6.0.0 [#1164](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1164) ([carabasdaniel](https://github.com/carabasdaniel)) ### Added @@ -388,6 +405,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a [Full Changelog](https://github.com/puppetlabs/puppetlabs-stdlib/compare/5.2.0...v6.0.0) ### Changed + - pdksync - (MODULES-8444) - Raise lower Puppet bound [#1011](https://github.com/puppetlabs/puppetlabs-stdlib/pull/1011) ([david22swan](https://github.com/david22swan)) ### Added diff --git a/metadata.json b/metadata.json index d458abfa7..6ad792c81 100644 --- a/metadata.json +++ b/metadata.json @@ -1,6 +1,6 @@ { "name": "puppetlabs-stdlib", - "version": "9.6.0", + "version": "9.7.0", "author": "puppetlabs", "summary": "Standard library of resources for Puppet modules.", "license": "Apache-2.0", From 2a25b6d4c251500b77c340ceb7be45f69c9a15f5 Mon Sep 17 00:00:00 2001 From: Alexander Fisher Date: Tue, 11 Feb 2025 21:21:13 +0000 Subject: [PATCH 20/25] Fix `has_ip_address` and `has_ip_network` functions The functions were using the old legacy function API. This meant that when they called `has_interface_with`, they were calling the legacy implementation of that function and not the v4 API version introduced in bc218f01497da494a499a4ab5d5fadb0ac278a37. Only in the v4 API implementation was the modern `networking` structured fact being used. The old `parser/functions/has_interface_with.rb` version still used legacy facts that are now not included in Puppet 8 by default. In this commit, we replace the `has_ip_address` and `has_ip_network` functions with namespaced Puppet language functions, (these functions are simple enough to not need ruby). Non-namespaced versions are added (but marked as deprecated) in `lib/puppet/functions`. The old implementations are removed completely. This is _almost_ certainly not going to be a breaking change for anyone. (Only other legacy functions which in turn call these functions could be affected). Fixes #1447 --- REFERENCE.md | 109 +++++++++--------- functions/has_ip_address.pp | 10 ++ functions/has_ip_network.pp | 10 ++ lib/puppet/functions/has_ip_address.rb | 14 +++ lib/puppet/functions/has_ip_network.rb | 14 +++ .../parser/functions/has_interface_with.rb | 68 ----------- lib/puppet/parser/functions/has_ip_address.rb | 27 ----- lib/puppet/parser/functions/has_ip_network.rb | 27 ----- spec/functions/has_ip_address_spec.rb | 21 ++-- spec/functions/has_ip_network_spec.rb | 19 ++- 10 files changed, 131 insertions(+), 188 deletions(-) create mode 100644 functions/has_ip_address.pp create mode 100644 functions/has_ip_network.pp create mode 100644 lib/puppet/functions/has_ip_address.rb create mode 100644 lib/puppet/functions/has_ip_network.rb delete mode 100644 lib/puppet/parser/functions/has_interface_with.rb delete mode 100644 lib/puppet/parser/functions/has_ip_address.rb delete mode 100644 lib/puppet/parser/functions/has_ip_network.rb diff --git a/REFERENCE.md b/REFERENCE.md index 63169ab67..a472419bc 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -63,9 +63,8 @@ environment. * [`grep`](#grep): This function searches through an array and returns any elements that match the provided regular expression. * [`has_interface_with`](#has_interface_with): DEPRECATED. Use the namespaced function [`stdlib::has_interface_with`](#stdlibhas_interface_with) instead. -* [`has_interface_with`](#has_interface_with): Returns boolean based on kind and value. -* [`has_ip_address`](#has_ip_address): Returns true if the client has the requested IP address on some interface. -* [`has_ip_network`](#has_ip_network): Returns true if the client has an IP address within the requested network. +* [`has_ip_address`](#has_ip_address): DEPRECATED. Use the namespaced function [`stdlib::has_ip_address`](#stdlibhas_ip_address) instead. +* [`has_ip_network`](#has_ip_network): DEPRECATED. Use the namespaced function [`stdlib::has_ip_network`](#stdlibhas_ip_network) instead. * [`intersection`](#intersection): This function returns an array of the intersection of two. * [`is_a`](#is_a): Boolean check to determine whether a variable is of a given data type. This is equivalent to the `=~` type checks. @@ -126,6 +125,8 @@ optional seed for repeatable randomness. * [`stdlib::fqdn_rotate`](#stdlib--fqdn_rotate): Rotates an array or string a random number of times, combining the `fqdn` fact and an optional seed for repeatable randomness. * [`stdlib::has_function`](#stdlib--has_function): Returns whether the Puppet runtime has access to a given function. * [`stdlib::has_interface_with`](#stdlib--has_interface_with): Returns boolean based on network interfaces present and their attribute values. +* [`stdlib::has_ip_address`](#stdlib--has_ip_address): Returns true if the client has the requested IPv4 address on some interface. +* [`stdlib::has_ip_network`](#stdlib--has_ip_network): Returns true if the client has the requested IPv4 network on some interface. * [`stdlib::ip_in_range`](#stdlib--ip_in_range): Returns true if the ipaddress is within the given CIDRs * [`stdlib::merge`](#stdlib--merge): Merges two or more hashes together or hashes resulting from iteration, and returns the resulting hash. @@ -2052,75 +2053,41 @@ Data type: `Any` -### `has_interface_with` - -Type: Ruby 3.x API - -Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. - -#### Examples - -##### **Usage** - -```puppet -has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` -has_interface_with("ipaddress", "127.0.0.1") # Returns `true` -``` - -##### If no "kind" is given, then the presence of the interface is checked: - -```puppet -has_interface_with("lo") # Returns `true` -``` +### `has_ip_address` -#### `has_interface_with()` +Type: Ruby 4.x API -Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. +DEPRECATED. Use the namespaced function [`stdlib::has_ip_address`](#stdlibhas_ip_address) instead. -Returns: `Any` boolean values `true` or `false` +#### `has_ip_address(Any *$args)` -##### Examples +The has_ip_address function. -###### **Usage** - -```puppet -has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` -has_interface_with("ipaddress", "127.0.0.1") # Returns `true` -``` +Returns: `Any` -###### If no "kind" is given, then the presence of the interface is checked: +##### `*args` -```puppet -has_interface_with("lo") # Returns `true` -``` +Data type: `Any` -### `has_ip_address` -Type: Ruby 3.x API -This function iterates through the 'interfaces' fact and checks the -'ipaddress_IFACE' facts, performing a simple string comparison. +### `has_ip_network` -#### `has_ip_address()` +Type: Ruby 4.x API -This function iterates through the 'interfaces' fact and checks the -'ipaddress_IFACE' facts, performing a simple string comparison. +DEPRECATED. Use the namespaced function [`stdlib::has_ip_network`](#stdlibhas_ip_network) instead. -Returns: `Boolean` `true` or `false` +#### `has_ip_network(Any *$args)` -### `has_ip_network` +The has_ip_network function. -Type: Ruby 3.x API +Returns: `Any` -This function iterates through the 'interfaces' fact and checks the -'network_IFACE' facts, performing a simple string comparision. +##### `*args` -#### `has_ip_network()` +Data type: `Any` -This function iterates through the 'interfaces' fact and checks the -'network_IFACE' facts, performing a simple string comparision. -Returns: `Any` Boolean value, `true` if the client has an IP address within the requested network. ### `intersection` @@ -3575,6 +3542,42 @@ Data type: `String[1]` The value of the attribute +### `stdlib::has_ip_address` + +Type: Puppet Language + +Returns true if the client has the requested IPv4 address on some interface. + +#### `stdlib::has_ip_address(Stdlib::IP::Address::V4::Nosubnet $ip_address)` + +The stdlib::has_ip_address function. + +Returns: `Boolean` Returns `true` if the requested IP address exists on any interface. + +##### `ip_address` + +Data type: `Stdlib::IP::Address::V4::Nosubnet` + +The IPv4 address you want to check the existence of + +### `stdlib::has_ip_network` + +Type: Puppet Language + +Returns true if the client has the requested IPv4 network on some interface. + +#### `stdlib::has_ip_network(Stdlib::IP::Address::V4::Nosubnet $ip_network)` + +The stdlib::has_ip_network function. + +Returns: `Boolean` Returns `true` if the requested IP network exists on any interface. + +##### `ip_network` + +Data type: `Stdlib::IP::Address::V4::Nosubnet` + +The IPv4 network you want to check the existence of + ### `stdlib::ip_in_range` Type: Ruby 4.x API diff --git a/functions/has_ip_address.pp b/functions/has_ip_address.pp new file mode 100644 index 000000000..d8d7e6a79 --- /dev/null +++ b/functions/has_ip_address.pp @@ -0,0 +1,10 @@ +# @summary Returns true if the client has the requested IPv4 address on some interface. +# +# @param ip_address +# The IPv4 address you want to check the existence of +# @return [Boolean] Returns `true` if the requested IP address exists on any interface. +function stdlib::has_ip_address( + Stdlib::IP::Address::V4::Nosubnet $ip_address, +) >> Boolean { + stdlib::has_interface_with('ipaddress', $ip_address) +} diff --git a/functions/has_ip_network.pp b/functions/has_ip_network.pp new file mode 100644 index 000000000..b6b9cb0f8 --- /dev/null +++ b/functions/has_ip_network.pp @@ -0,0 +1,10 @@ +# @summary Returns true if the client has the requested IPv4 network on some interface. +# +# @param ip_network +# The IPv4 network you want to check the existence of +# @return [Boolean] Returns `true` if the requested IP network exists on any interface. +function stdlib::has_ip_network( + Stdlib::IP::Address::V4::Nosubnet $ip_network, +) >> Boolean { + stdlib::has_interface_with('network', $ip_network) +} diff --git a/lib/puppet/functions/has_ip_address.rb b/lib/puppet/functions/has_ip_address.rb new file mode 100644 index 000000000..392d5c550 --- /dev/null +++ b/lib/puppet/functions/has_ip_address.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` + +# @summary DEPRECATED. Use the namespaced function [`stdlib::has_ip_address`](#stdlibhas_ip_address) instead. +Puppet::Functions.create_function(:has_ip_address) do + dispatch :deprecation_gen do + repeated_param 'Any', :args + end + def deprecation_gen(*args) + call_function('deprecation', 'has_ip_address', 'This function is deprecated, please use stdlib::has_ip_address instead.', false) + call_function('stdlib::has_ip_address', *args) + end +end diff --git a/lib/puppet/functions/has_ip_network.rb b/lib/puppet/functions/has_ip_network.rb new file mode 100644 index 000000000..b0219b671 --- /dev/null +++ b/lib/puppet/functions/has_ip_network.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +# THIS FILE WAS GENERATED BY `rake regenerate_unamespaced_shims` + +# @summary DEPRECATED. Use the namespaced function [`stdlib::has_ip_network`](#stdlibhas_ip_network) instead. +Puppet::Functions.create_function(:has_ip_network) do + dispatch :deprecation_gen do + repeated_param 'Any', :args + end + def deprecation_gen(*args) + call_function('deprecation', 'has_ip_network', 'This function is deprecated, please use stdlib::has_ip_network instead.', false) + call_function('stdlib::has_ip_network', *args) + end +end diff --git a/lib/puppet/parser/functions/has_interface_with.rb b/lib/puppet/parser/functions/has_interface_with.rb deleted file mode 100644 index b78029d08..000000000 --- a/lib/puppet/parser/functions/has_interface_with.rb +++ /dev/null @@ -1,68 +0,0 @@ -# frozen_string_literal: true - -# -# has_interface_with -# -module Puppet::Parser::Functions - newfunction(:has_interface_with, type: :rvalue, doc: <<-DOC - @summary - Returns boolean based on kind and value. - - @return - boolean values `true` or `false` - - Valid kinds are `macaddress`, `netmask`, `ipaddress` and `network`. - - @example **Usage** - has_interface_with("macaddress", "x:x:x:x:x:x") # Returns `false` - has_interface_with("ipaddress", "127.0.0.1") # Returns `true` - - @example If no "kind" is given, then the presence of the interface is checked: - has_interface_with("lo") # Returns `true` - DOC - ) do |args| - raise(Puppet::ParseError, "has_interface_with(): Wrong number of arguments given (#{args.size} for 1 or 2)") if args.empty? || args.size > 2 - - interfaces = lookupvar('interfaces') - - # If we do not have any interfaces, then there are no requested attributes - return false if interfaces == :undefined || interfaces.nil? - - interfaces = interfaces.split(',') - - return interfaces.member?(args[0]) if args.size == 1 - - kind, value = args - - # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable - # https://tickets.puppetlabs.com/browse/PUP-3597 - factval = nil - begin - catch :undefined_variable do - factval = lookupvar(kind) - end - rescue Puppet::ParseError - end - return true if factval == value - - result = false - interfaces.each do |iface| - iface.downcase! - factval = nil - begin - # Bug with 3.7.1 - 3.7.3 when using future parser throws :undefined_variable - # https://tickets.puppetlabs.com/browse/PUP-3597 - catch :undefined_variable do - factval = lookupvar("#{kind}_#{iface}") - end - rescue Puppet::ParseError - end - if value == factval - result = true - break - end - end - - result - end -end diff --git a/lib/puppet/parser/functions/has_ip_address.rb b/lib/puppet/parser/functions/has_ip_address.rb deleted file mode 100644 index 763813c22..000000000 --- a/lib/puppet/parser/functions/has_ip_address.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# -# has_ip_address -# -module Puppet::Parser::Functions - newfunction(:has_ip_address, type: :rvalue, doc: <<-DOC - @summary - Returns true if the client has the requested IP address on some interface. - - @return [Boolean] - `true` or `false` - - This function iterates through the 'interfaces' fact and checks the - 'ipaddress_IFACE' facts, performing a simple string comparison. - DOC - ) do |args| - raise(Puppet::ParseError, "has_ip_address(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 - - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ - unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) - - function_has_interface_with(['ipaddress', args[0]]) - end -end - -# vim:sts=2 sw=2 diff --git a/lib/puppet/parser/functions/has_ip_network.rb b/lib/puppet/parser/functions/has_ip_network.rb deleted file mode 100644 index b556d97c0..000000000 --- a/lib/puppet/parser/functions/has_ip_network.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -# -# has_ip_network -# -module Puppet::Parser::Functions - newfunction(:has_ip_network, type: :rvalue, doc: <<-DOC - @summary - Returns true if the client has an IP address within the requested network. - - @return - Boolean value, `true` if the client has an IP address within the requested network. - - This function iterates through the 'interfaces' fact and checks the - 'network_IFACE' facts, performing a simple string comparision. - DOC - ) do |args| - raise(Puppet::ParseError, "has_ip_network(): Wrong number of arguments given (#{args.size} for 1)") if args.size != 1 - - Puppet::Parser::Functions.autoloader.load(:has_interface_with) \ - unless Puppet::Parser::Functions.autoloader.loaded?(:has_interface_with) - - function_has_interface_with(['network', args[0]]) - end -end - -# vim:sts=2 sw=2 diff --git a/spec/functions/has_ip_address_spec.rb b/spec/functions/has_ip_address_spec.rb index 5b787d693..7256e7518 100644 --- a/spec/functions/has_ip_address_spec.rb +++ b/spec/functions/has_ip_address_spec.rb @@ -4,22 +4,29 @@ describe 'has_ip_address' do it { is_expected.not_to be_nil } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::has_ip_address' expects 1 argument, got none}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{'stdlib::has_ip_address' expects 1 argument, got 2}) } context 'when on Linux Systems' do let(:facts) do { - interfaces: 'eth0,lo', - ipaddress: '10.0.0.1', - ipaddress_lo: '127.0.0.1', - ipaddress_eth0: '10.0.0.1' + networking: { + 'interfaces' => { + 'eth0' => { + 'ip' => '10.0.0.1', + }, + 'lo' => { + 'ip' => '127.0.0.1', + }, + }, + 'ip' => '10.0.0.1', + }, } end it { is_expected.to run.with_params('127.0.0.1').and_return(true) } it { is_expected.to run.with_params('10.0.0.1').and_return(true) } it { is_expected.to run.with_params('8.8.8.8').and_return(false) } - it { is_expected.to run.with_params('invalid').and_return(false) } + it { is_expected.to run.with_params('invalid').and_raise_error(ArgumentError, %r{parameter 'ip_address' expects a match}) } end end diff --git a/spec/functions/has_ip_network_spec.rb b/spec/functions/has_ip_network_spec.rb index 22564bb71..c8352272e 100644 --- a/spec/functions/has_ip_network_spec.rb +++ b/spec/functions/has_ip_network_spec.rb @@ -4,21 +4,28 @@ describe 'has_ip_network' do it { is_expected.not_to be_nil } - it { is_expected.to run.with_params.and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } - it { is_expected.to run.with_params('one', 'two').and_raise_error(Puppet::ParseError, %r{wrong number of arguments}i) } + it { is_expected.to run.with_params.and_raise_error(ArgumentError, %r{'stdlib::has_ip_network' expects 1 argument, got none}) } + it { is_expected.to run.with_params('one', 'two').and_raise_error(ArgumentError, %r{'stdlib::has_ip_network' expects 1 argument, got 2}) } context 'when on Linux Systems' do let(:facts) do { - interfaces: 'eth0,lo', - network_lo: '127.0.0.0', - network_eth0: '10.0.0.0' + networking: { + 'interfaces' => { + 'eth0' => { + 'network' => '10.0.0.0', + }, + 'lo' => { + 'network' => '127.0.0.0', + }, + }, + }, } end it { is_expected.to run.with_params('127.0.0.0').and_return(true) } it { is_expected.to run.with_params('10.0.0.0').and_return(true) } it { is_expected.to run.with_params('8.8.8.0').and_return(false) } - it { is_expected.to run.with_params('invalid').and_return(false) } + it { is_expected.to run.with_params('invalid').and_raise_error(ArgumentError, %r{parameter 'ip_network' expects a match}) } end end From 3bcb965cd5f888579d025474ca06ab4aee2f4b71 Mon Sep 17 00:00:00 2001 From: Shubham Shinde Date: Tue, 22 Apr 2025 12:45:39 +0530 Subject: [PATCH 21/25] (CAT-2296) Update github runner image to ubuntu-24.04 ubuntu-20.04 is not supported anymore: https://github.com/actions/runner-images/issues/11101 --- .github/workflows/ci.yml | 2 +- .github/workflows/nightly.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1b0e39c35..42e7a6e0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,4 +16,4 @@ jobs: uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" with: - runs_on: "ubuntu-20.04" + runs_on: "ubuntu-24.04" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index aaa4967f9..6e3017ba9 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -15,4 +15,4 @@ jobs: uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" with: - runs_on: "ubuntu-20.04" + runs_on: "ubuntu-24.04" From 1af4ff3feee195161b3fcc2f1b360d973c387d68 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Fri, 25 Jul 2025 10:08:21 +0100 Subject: [PATCH 22/25] (CAT-2395) Puppetcore upgrade A set of changes dedicated to implementing puppetcore into our modules. This update, amongst other changes, removes Puppet 7 support. --- metadata.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metadata.json b/metadata.json index 6ad792c81..b231b90ec 100644 --- a/metadata.json +++ b/metadata.json @@ -109,7 +109,7 @@ "requirements": [ { "name": "puppet", - "version_requirement": ">= 7.0.0 < 9.0.0" + "version_requirement": ">= 8.0.0 < 9.0.0" } ], "description": "Standard Library for Puppet Modules", From 9b0133a4c2b6475f4f0ddf72966a8845cb5ee15a Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Fri, 25 Jul 2025 10:09:40 +0100 Subject: [PATCH 23/25] pdk update --- .github/workflows/ci.yml | 2 -- .github/workflows/nightly.yml | 2 -- .puppet-lint.rc | 8 +++++++ .rubocop.yml | 2 +- Gemfile | 41 ++++++++++++++++++++--------------- Rakefile | 9 ++++++++ metadata.json | 4 ++-- 7 files changed, 43 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 42e7a6e0f..a5738adb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,5 +15,3 @@ jobs: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" - with: - runs_on: "ubuntu-24.04" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 6e3017ba9..1b06c4717 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -14,5 +14,3 @@ jobs: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" secrets: "inherit" - with: - runs_on: "ubuntu-24.04" diff --git a/.puppet-lint.rc b/.puppet-lint.rc index cc96ece05..9e15c6e01 100644 --- a/.puppet-lint.rc +++ b/.puppet-lint.rc @@ -1 +1,9 @@ +--fail-on-warnings --relative +--no-80chars-check +--no-140chars-check +--no-class_inherits_from_params_class-check +--no-autoloader_layout-check +--no-documentation-check +--no-single_quote_string_with_variables-check +--ignore-paths=.vendor/**/*.pp,.bundle/**/*.pp,pkg/**/*.pp,spec/**/*.pp,tests/**/*.pp,types/**/*.pp,vendor/**/*.pp diff --git a/.rubocop.yml b/.rubocop.yml index 439ea84ee..47b1aadbe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,7 +5,7 @@ require: AllCops: NewCops: enable DisplayCopNames: true - TargetRubyVersion: '2.6' + TargetRubyVersion: 3.1 Include: - "**/*.rb" Exclude: diff --git a/Gemfile b/Gemfile index 2d8e1608b..6dd3b77cc 100644 --- a/Gemfile +++ b/Gemfile @@ -14,50 +14,55 @@ 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 "deep_merge", '~> 1.2.2', require: false gem "voxpupuli-puppet-lint-plugins", '~> 5.0', require: false - gem "facterdb", '~> 2.1', require: false + gem "facterdb", '~> 2.1', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "facterdb", '~> 3.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) gem "metadata-json-lint", '~> 4.0', require: false - gem "rspec-puppet-facts", '~> 4.0', require: false + gem "json-schema", '< 5.1.1', require: false + gem "rspec-puppet-facts", '~> 4.0', require: false if Gem::Requirement.create(['< 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) + gem "rspec-puppet-facts", '~> 5.0', require: false if Gem::Requirement.create(['>= 3.0.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup)) 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.9', require: false - gem "puppet-debugger", '~> 1.0', require: false + gem "puppet-debugger", '~> 1.6', require: false gem "rubocop", '~> 1.50.0', require: false gem "rubocop-performance", '= 1.16.0', require: false gem "rubocop-rspec", '= 2.19.0', require: false gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw] - gem "rexml", '>= 3.3.9', require: false + gem "bigdecimal", '< 3.2.2', require: false, platforms: [:mswin, :mingw, :x64_mingw] end group :development, :release_prep do gem "puppet-strings", '~> 4.0', require: false - gem "puppetlabs_spec_helper", '~> 7.0', require: false + gem "puppetlabs_spec_helper", '~> 8.0', require: false + gem "puppet-blacksmith", '~> 7.0', require: false end group :system_tests do - gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] + gem "puppet_litmus", '~> 2.0', require: false, platforms: [:ruby, :x64_mingw] if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gem "puppet_litmus", '~> 1.0', require: false, platforms: [:ruby, :x64_mingw] if ENV['PUPPET_FORGE_TOKEN'].to_s.empty? gem "CFPropertyList", '< 3.0.7', require: false, platforms: [:mswin, :mingw, :x64_mingw] gem "serverspec", '~> 2.41', require: false end -puppet_version = ENV['PUPPET_GEM_VERSION'] -facter_version = ENV['FACTER_GEM_VERSION'] -hiera_version = ENV['HIERA_GEM_VERSION'] - gems = {} +puppet_version = ENV.fetch('PUPPET_GEM_VERSION', nil) +facter_version = ENV.fetch('FACTER_GEM_VERSION', nil) +hiera_version = ENV.fetch('HIERA_GEM_VERSION', nil) -gems['puppet'] = location_for(puppet_version) - -# If facter or hiera versions have been specified via the environment -# variables +# If PUPPET_FORGE_TOKEN is set then use authenticated source for both puppet and facter, since facter is a transitive dependency of puppet +# Otherwise, do as before and use location_for to fetch gems from the default source +if !ENV['PUPPET_FORGE_TOKEN'].to_s.empty? + gems['puppet'] = ['~> 8.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] + gems['facter'] = ['~> 4.11', { require: false, source: 'https://rubygems-puppetcore.puppet.com' }] +else + gems['puppet'] = location_for(puppet_version) + gems['facter'] = location_for(facter_version) if facter_version +end -gems['facter'] = location_for(facter_version) if facter_version gems['hiera'] = location_for(hiera_version) if hiera_version gems.each do |gem_name, gem_params| diff --git a/Rakefile b/Rakefile index 77590fe6f..31b593053 100644 --- a/Rakefile +++ b/Rakefile @@ -7,3 +7,12 @@ require 'puppet-syntax/tasks/puppet-syntax' require 'puppet-strings/tasks' if Gem.loaded_specs.key? 'puppet-strings' PuppetLint.configuration.send('disable_relative') +PuppetLint.configuration.send('disable_80chars') +PuppetLint.configuration.send('disable_140chars') +PuppetLint.configuration.send('disable_class_inherits_from_params_class') +PuppetLint.configuration.send('disable_autoloader_layout') +PuppetLint.configuration.send('disable_documentation') +PuppetLint.configuration.send('disable_single_quote_string_with_variables') +PuppetLint.configuration.fail_on_warnings = true +PuppetLint.configuration.ignore_paths = [".vendor/**/*.pp", ".bundle/**/*.pp", "pkg/**/*.pp", "spec/**/*.pp", "tests/**/*.pp", "types/**/*.pp", "vendor/**/*.pp"] + diff --git a/metadata.json b/metadata.json index b231b90ec..c997c0457 100644 --- a/metadata.json +++ b/metadata.json @@ -113,7 +113,7 @@ } ], "description": "Standard Library for Puppet Modules", - "pdk-version": "3.2.0", + "pdk-version": "3.5.0", "template-url": "https://github.com/puppetlabs/pdk-templates#main", - "template-ref": "tags/3.2.0.4-0-g5d17ec1" + "template-ref": "heads/main-0-g11c0f3d" } From 11232b2bb9ac838d0f051c61c3bdb778aa2c54f4 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Fri, 25 Jul 2025 10:15:27 +0100 Subject: [PATCH 24/25] Rubocop safe autocorrections --- lib/puppet/parser/functions/parseyaml.rb | 2 +- lib/puppet/parser/functions/validate_augeas.rb | 2 +- spec/unit/puppet/provider/file_line/ruby_alter_spec.rb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puppet/parser/functions/parseyaml.rb b/lib/puppet/parser/functions/parseyaml.rb index e1036386a..014c12d26 100644 --- a/lib/puppet/parser/functions/parseyaml.rb +++ b/lib/puppet/parser/functions/parseyaml.rb @@ -22,7 +22,7 @@ module Puppet::Parser::Functions require 'yaml' begin - YAML.load(arguments[0]) || arguments[1] # rubocop:disable Security/YAMLLoad : using YAML.safe_load causes the code to break + YAML.load(arguments[0]) || arguments[1] # : using YAML.safe_load causes the code to break # in ruby 1.9.3 Psych::SyntaxError is a RuntimeException # this still needs to catch that and work also on rubies that # do not have Psych available. diff --git a/lib/puppet/parser/functions/validate_augeas.rb b/lib/puppet/parser/functions/validate_augeas.rb index 8d89b1e7d..31df4cd66 100644 --- a/lib/puppet/parser/functions/validate_augeas.rb +++ b/lib/puppet/parser/functions/validate_augeas.rb @@ -67,7 +67,7 @@ module Puppet::Parser::Functions # Check for syntax lens = args[1] aug.transform( - lens: lens, + lens:, name: 'Validate_augeas', incl: tmpfile.path, ) diff --git a/spec/unit/puppet/provider/file_line/ruby_alter_spec.rb b/spec/unit/puppet/provider/file_line/ruby_alter_spec.rb index 8b10a413c..310ac5c97 100644 --- a/spec/unit/puppet/provider/file_line/ruby_alter_spec.rb +++ b/spec/unit/puppet/provider/file_line/ruby_alter_spec.rb @@ -172,8 +172,8 @@ name: 'foo', path: tmpfile, line: 'inserted = line', - after: after, - match: match, + after:, + match:, ) end end From 289c4c40200ee36dc0601e7d01b7eb4a2e1b6e89 Mon Sep 17 00:00:00 2001 From: Lukas Audzevicius Date: Wed, 13 Aug 2025 07:48:57 +0100 Subject: [PATCH 25/25] Test against nightlies --- .github/workflows/ci.yml | 2 ++ .github/workflows/nightly.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a5738adb8..2cdfc30f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,4 +14,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--nightly" secrets: "inherit" diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 1b06c4717..5a39a47c7 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -13,4 +13,6 @@ jobs: Acceptance: needs: Spec uses: "puppetlabs/cat-github-actions/.github/workflows/module_acceptance.yml@main" + with: + flags: "--nightly" secrets: "inherit"