Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port code to Puppet 7 and 8 #5

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
fixtures:
repositories:
stdlib:
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -4,7 +4,12 @@

name: CI

on: pull_request
on:
pull_request: {}
push:
branches:
- main
- master

concurrency:
group: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion .msync.yml
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
# Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/

modulesync_config_version: '7.2.0'
modulesync_config_version: '7.3.0'
10 changes: 5 additions & 5 deletions manifests/files.pp
Original file line number Diff line number Diff line change
@@ -33,15 +33,15 @@
#
define swap_file::files (
Enum['absent','present'] $ensure = 'present',
Stdlib::Unixpath $swapfile = '/mnt/swap.1',
Stdlib::Absolutepath $swapfile = '/mnt/swap.1',
$swapfilesize = $facts['memory']['system']['total'],
Boolean $add_mount = true,
$options = 'defaults',
String $options = 'defaults',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good but we should re-enable the tests which are disabled in puppet-lint.rc or whatever it is... Actually am a bit confused why the modulesync did not fix the file.

$timeout = 300,
$cmd = 'dd',
$resize_existing = false,
String $cmd = 'dd',
Bootlan $resize_existing = false,
$resize_margin = '50MB',
$resize_verbose = false,
Boolean $resize_verbose = false,
) {
# Parameter validation
$swapfilesize_mb = to_bytes($swapfilesize) / 1048576
15 changes: 4 additions & 11 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -40,19 +40,12 @@
# @author - Peter Souter
#
class swap_file (
Hash $files = {},
Variant[Boolean,Enum['true','false']] $files_hiera_merge = false,
Hash $files = {},
Boolean $files_hiera_merge = false,
) {
# variable handling
if $files_hiera_merge =~ Boolean {
$files_hiera_merge_bool = $files_hiera_merge
} else {
$files_hiera_merge_bool = str2bool($files_hiera_merge)
}

# functionality
if $files_hiera_merge_bool == true {
$files_real = lookup('swap_file::files', Hash, 'deep', {})
if $files_hiera_merge {
$files_real = hiera_hash('swap_file::files', {})
} else {
$files_real = $files
}
6 changes: 3 additions & 3 deletions manifests/resize.pp
Original file line number Diff line number Diff line change
@@ -16,11 +16,11 @@
# @author - Peter Souter
#
define swap_file::resize (
$swapfile_path,
Stdlib::Absolutepath $swapfile_path,
$expected_swapfile_size,
$actual_swapfile_size,
$margin = '50MB',
$verbose = false,
$margin = '50MB',
Boolean $verbose = false,
) {
$margin_bytes = to_bytes($margin)
$existing_swapfile_bytes = to_bytes("${actual_swapfile_size}kb")
22 changes: 15 additions & 7 deletions metadata.json
Original file line number Diff line number Diff line change
@@ -11,23 +11,31 @@
{
"operatingsystem": "RedHat",
"operatingsystemrelease": [
"5",
"6",
"7"
"7",
"8",
"9"
]
},
{
"operatingsystem": "CentOS",
"operatingsystemrelease": [
"7",
"8",
"9"
]
},
{
"operatingsystem": "Debian",
"operatingsystemrelease": [
"6",
"7"
"11",
"12"
]
},
{
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04",
"14.04"
"20.04",
"22.04"
]
}
],

Unchanged files with check annotations Beta

# Puppet::Util::Log.newdestination(:console)
context 'default parameters' do
it do

Check failure on line 25 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 default parameters is expected to compile into a catalogue without dependency cycles Failure/Error: is_expected.to compile.with_all_deps error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 25 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 default parameters is expected to compile into a catalogue without dependency cycles Failure/Error: is_expected.to compile.with_all_deps error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to compile.with_all_deps
end
it do

Check failure on line 29 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 default parameters is expected to contain Exec[Create swap file /mnt/swap.1] with command => "/bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=1024" and creates => "/mnt/swap.1" Failure/Error: is_expected.to contain_exec('Create swap file /mnt/swap.1'). with('command' => '/bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=1024', 'creates' => '/mnt/swap.1') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 29 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 default parameters is expected to contain Exec[Create swap file /mnt/swap.1] with command => "/bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=1024" and creates => "/mnt/swap.1" Failure/Error: is_expected.to contain_exec('Create swap file /mnt/swap.1'). with('command' => '/bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=1024', 'creates' => '/mnt/swap.1') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to contain_exec('Create swap file /mnt/swap.1').
with('command' => '/bin/dd if=/dev/zero of=/mnt/swap.1 bs=1M count=1024',
'creates' => '/mnt/swap.1')
end
it do

Check failure on line 35 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 default parameters is expected to contain File[/mnt/swap.1] with owner => "root", group => "root", mode => "0600" and require => "Exec[Create swap file /mnt/swap.1]" Failure/Error: is_expected.to contain_file('/mnt/swap.1'). with('owner' => 'root', 'group' => 'root', 'mode' => '0600', 'require' => 'Exec[Create swap file /mnt/swap.1]') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 35 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 default parameters is expected to contain File[/mnt/swap.1] with owner => "root", group => "root", mode => "0600" and require => "Exec[Create swap file /mnt/swap.1]" Failure/Error: is_expected.to contain_file('/mnt/swap.1'). with('owner' => 'root', 'group' => 'root', 'mode' => '0600', 'require' => 'Exec[Create swap file /mnt/swap.1]') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to contain_file('/mnt/swap.1').
with('owner' => 'root',
'group' => 'root',
'require' => 'Exec[Create swap file /mnt/swap.1]')
end
it do

Check failure on line 43 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 default parameters is expected to contain Swap_file[/mnt/swap.1] Failure/Error: is_expected.to contain_swap_file('/mnt/swap.1') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 43 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 default parameters is expected to contain Swap_file[/mnt/swap.1] Failure/Error: is_expected.to contain_swap_file('/mnt/swap.1') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to contain_swap_file('/mnt/swap.1')
end
it do

Check failure on line 47 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 default parameters is expected to contain Mount[/mnt/swap.1] with require => "Swap_file[/mnt/swap.1]" Failure/Error: is_expected.to contain_mount('/mnt/swap.1'). with('require' => 'Swap_file[/mnt/swap.1]') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 47 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 default parameters is expected to contain Mount[/mnt/swap.1] with require => "Swap_file[/mnt/swap.1]" Failure/Error: is_expected.to contain_mount('/mnt/swap.1'). with('require' => 'Swap_file[/mnt/swap.1]') Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to contain_mount('/mnt/swap.1').
with('require' => 'Swap_file[/mnt/swap.1]')
end
}
end
it do

Check failure on line 60 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file::files on centos-7-x86_64 custom swapfilesize parameter is expected to compile into a catalogue without dependency cycles Failure/Error: is_expected.to compile.with_all_deps error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 60 in spec/defines/files_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file::files on debian-11-x86_64 custom swapfilesize parameter is expected to compile into a catalogue without dependency cycles Failure/Error: is_expected.to compile.with_all_deps error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to compile.with_all_deps
end
}
end
it { is_expected.to compile.with_all_deps }

Check failure on line 38 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file on centos-7-x86_64 with files set to valid hash is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 38 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file on debian-11-x86_64 with files set to valid hash is expected to compile into a catalogue without dependency cycles Failure/Error: it { is_expected.to compile.with_all_deps } error during compilation: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
it { is_expected.to contain_class('swap_file') }

Check failure on line 39 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file on centos-7-x86_64 with files set to valid hash is expected to contain Class[swap_file] Failure/Error: it { is_expected.to contain_class('swap_file') } Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 39 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file on debian-11-x86_64 with files set to valid hash is expected to contain Class[swap_file] Failure/Error: it { is_expected.to contain_class('swap_file') } Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
# subclass swap_file::files adds 4 resources for each given file
it { is_expected.to have_resource_count(10) }

Check failure on line 41 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file on centos-7-x86_64 with files set to valid hash is expected to contain exactly 10 resources Failure/Error: it { is_expected.to have_resource_count(10) } Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 41 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file on debian-11-x86_64 with files set to valid hash is expected to contain exactly 10 resources Failure/Error: it { is_expected.to have_resource_count(10) } Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
it do

Check failure on line 43 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 8 (Ruby 3.2)

swap_file on centos-7-x86_64 with files set to valid hash is expected to contain Swap_file::Files[swap] with ensure => "present" Failure/Error: is_expected.to contain_swap_file__files('swap').with({ 'ensure' => 'present', }) Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az523-365.sep422n2mygejbgjkrbwxz25qb.ex.internal.cloudapp.net

Check failure on line 43 in spec/classes/init_spec.rb

GitHub Actions / Puppet / 7 (Ruby 2.7)

swap_file on debian-11-x86_64 with files set to valid hash is expected to contain Swap_file::Files[swap] with ensure => "present" Failure/Error: is_expected.to contain_swap_file__files('swap').with({ 'ensure' => 'present', }) Puppet::PreformattedError: Evaluation Error: Resource type not found: Bootlan (file: /home/runner/work/puppet-swap_file/puppet-swap_file/spec/fixtures/modules/swap_file/manifests/files.pp, line: 42, column: 3) on node fv-az985-19.4j5qjbg331oedl4sqeow5vdphg.cx.internal.cloudapp.net
is_expected.to contain_swap_file__files('swap').with({
'ensure' => 'present',
})