Skip to content

Commit

Permalink
BREAKING: Updates, Drop Puppet 6 and add Puppet 8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock committed Sep 19, 2023
1 parent 11a29ff commit 9393e56
Show file tree
Hide file tree
Showing 18 changed files with 88 additions and 93 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
- master
pull_request:


jobs:
unit:
runs-on: ubuntu-latest
Expand All @@ -15,27 +16,27 @@ jobs:
fail-fast: false
matrix:
include:
- ruby: 2.5.7
puppet: 6
- ruby: 2.7.7
puppet: 7
fixtures: .fixtures.yml
allow_failure: false
- ruby: 2.7.0
puppet: 7
- ruby: 3.2.2
puppet: 8
fixtures: .fixtures.yml
allow_failure: false
env:
BUNDLE_WITHOUT: system_tests:release
PUPPET_GEM_VERSION: "~> ${{ matrix.puppet }}.0"
FACTER_GEM_VERSION: "< 4.0"
FIXTURES_YML: ${{ matrix.fixtures }}
name: Puppet ${{ matrix.puppet }} (Ruby ${{ matrix.ruby }})
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true
cache-version: 2
bundler: '2.1.0'
- name: Validate
run: bundle exec rake check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
Expand Down
35 changes: 10 additions & 25 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
---
require:
- rubocop-rspec
- rubocop-i18n
AllCops:
DisplayCopNames: true
TargetRubyVersion: '2.1'
TargetRubyVersion: '2.5'
Include:
- "./**/*.rb"
- "**/*.rb"
Exclude:
- bin/*
- ".vendor/**/*"
Expand All @@ -21,13 +20,6 @@ AllCops:
Metrics/LineLength:
Description: People have wide screens, use them.
Max: 200
GetText:
Enabled: false
GetText/DecorateString:
Description: We don't want to decorate test output.
Exclude:
- spec/**/*
Enabled: false
RSpec/BeforeAfterAll:
Description: Beware of using after(:all) as it may cause state to leak between tests.
A necessary evil in acceptance testing.
Expand All @@ -40,10 +32,6 @@ Style/BlockDelimiters:
Description: Prefer braces for chaining. Mostly an aesthetical choice. Better to
be consistent then.
EnforcedStyle: braces_for_chaining
Style/BracesAroundHashParameters:
Description: Braces are required by Ruby 2.7. Cop removed from RuboCop v0.80.0.
See https://github.com/rubocop-hq/rubocop/pull/7643
Enabled: true
Style/ClassAndModuleChildren:
Description: Compact style reduces the required amount of indentation.
EnforcedStyle: compact
Expand Down Expand Up @@ -72,13 +60,16 @@ Style/TrailingCommaInArguments:
Description: Prefer always trailing comma on multiline argument lists. This makes
diffs, and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/TrailingCommaInLiteral:
Description: Prefer always trailing comma on multiline literals. This makes diffs,
and re-ordering nicer.
EnforcedStyleForMultiline: comma
Style/SymbolArray:
Description: Using percent style obscures symbolic intent of array's contents.
EnforcedStyle: brackets
RSpec/ImplicitSubject:
Enabled: false
Lint/BooleanSymbol:
Enabled: false
Naming/MethodParameterName:
AllowedNames:
- is
RSpec/MessageSpies:
EnforcedStyle: receive
Style/Documentation:
Expand All @@ -93,15 +84,9 @@ Style/MethodCalledOnDoEndBlock:
Enabled: true
Style/StringMethods:
Enabled: true
GetText/DecorateFunctionMessage:
Enabled: false
GetText/DecorateStringFormattingUsingInterpolation:
Enabled: false
GetText/DecorateStringFormattingUsingPercent:
Enabled: false
Layout/EndOfLine:
Enabled: false
Layout/IndentHeredoc:
Layout/HeredocIndentation:
Enabled: false
Metrics/AbcSize:
Enabled: false
Expand Down
8 changes: 4 additions & 4 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
delete: true
appveyor.yml:
delete: true
spec/acceptance/nodesets/debian-8.yml:
delete: true
spec/acceptance/nodesets/debian-9.yml:
spec/acceptance/nodesets/el9.yml:
delete: true
spec/acceptance/nodesets/debian-10.yml:
delete: true
spec/acceptance/nodesets/ubuntu-1804.yml:
spec/acceptance/nodesets/debian-11.yml:
delete: true
spec/acceptance/nodesets/ubuntu-2004.yml:
delete: true
spec/acceptance/nodesets/ubuntu-2204.yml:
delete: true
26 changes: 9 additions & 17 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,22 @@ ruby_version_segments = Gem::Version.new(RUBY_VERSION.dup).segments
minor_version = ruby_version_segments[0..1].join('.')

group :development do
gem "fast_gettext", '1.1.0', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.1.0')
gem "fast_gettext", require: false if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.1.0')
gem "json_pure", '<= 2.0.1', require: false if Gem::Version.new(RUBY_VERSION.dup) < Gem::Version.new('2.0.0')
gem "json", '= 1.8.1', require: false if Gem::Version.new(RUBY_VERSION.dup) == Gem::Version.new('2.1.9')
gem "json", '= 2.0.4', require: false if Gem::Requirement.create('~> 2.4.2').satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "json", '= 2.1.0', require: false if Gem::Requirement.create(['>= 2.5.0', '< 2.7.0']).satisfied_by?(Gem::Version.new(RUBY_VERSION.dup))
gem "rb-readline", '= 0.5.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-posix-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
gem "puppet-module-posix-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:ruby]
gem "puppet-module-win-default-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-module-win-dev-r#{minor_version}", '~> 0.4', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "puppet-lint-param-docs", require: false
gem "github_changelog_generator", require: false
gem "voxpupuli-test", '7.0.0', require: false
gem "faraday", '~> 1.0', require: false
gem "github_changelog_generator", require: false
gem "puppet-blacksmith", require: false
gem "puppet-strings", require: false
end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", '~> 0.5', require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.29')
gem "beaker-abs", *location_for(ENV['BEAKER_ABS_VERSION'] || '~> 0.1')
gem "beaker-pe", require: false
gem "beaker-hostgenerator"
gem "beaker-rspec"
gem "beaker-docker", *location_for(ENV['BEAKER_DOCKER_VERSION'] || '~> 0.7.0')
gem "beaker-docker"
gem "beaker-puppet"
gem "beaker-puppet_install_helper", require: false
gem "beaker-module_install_helper", require: false
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'beaker-rspec/rake_task' if Bundler.rubygems.find_name('beaker-rspec').any?
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
require 'github_changelog_generator/task' if Bundler.rubygems.find_name('github_changelog_generator').any?
require 'puppet-strings/tasks' if Bundler.rubygems.find_name('puppet-strings').any?
Expand Down
8 changes: 4 additions & 4 deletions lib/facter/crashkernel.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: crashkernel
#
# Purpose:
Expand All @@ -15,10 +17,8 @@
setcode do
crashkernel = false
kernel_arguments = Facter.value(:kdump_kernel_arguments)
if kernel_arguments
if kernel_arguments =~ %r{crashkernel=(\S+)}
crashkernel = Regexp.last_match(1)
end
if kernel_arguments && (kernel_arguments =~ %r{crashkernel=(\S+)})
crashkernel = Regexp.last_match(1)
end
crashkernel
end
Expand Down
2 changes: 2 additions & 0 deletions lib/facter/kdump_kernel_arguments.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Fact: kdump_kernel_arguments
#
# Purpose:
Expand Down
10 changes: 4 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
Boolean $manage_kernel_parameter = true,
Optional[String] $grub_kdump_cfg = undef,
) {

$osfamily = dig($facts, 'os', 'family')
if ! ($osfamily in ['RedHat', 'Debian']) {
fail("Unsupported osfamily: ${osfamily}, module ${module_name} only support RedHat and Debian")
Expand Down Expand Up @@ -128,13 +127,13 @@
}

package { 'kexec-tools':
ensure => present,
ensure => 'installed',
name => $package_name,
before => File['/etc/kdump.conf'],
}

file { '/etc/kdump.conf':
ensure => present,
ensure => 'file',
path => $config_path,
content => template('kdump/kdump.conf.erb'),
owner => 'root',
Expand All @@ -145,7 +144,7 @@

if ! $facts['crashkernel'] {
notify { 'kdump':
message => 'A reboot is required to fully enable the crashkernel'
message => 'A reboot is required to fully enable the crashkernel',
}
}
} else {
Expand All @@ -168,7 +167,7 @@

if $facts['crashkernel'] {
notify { 'kdump':
message => 'A reboot is required to fully disable the crashkernel'
message => 'A reboot is required to fully disable the crashkernel',
}
}
}
Expand All @@ -180,5 +179,4 @@
hasstatus => $service_hasstatus,
hasrestart => $service_hasrestart,
}

}
6 changes: 3 additions & 3 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
"requirements": [
{
"name": "puppet",
"version_requirement": ">= 6.0.0 < 8.0.0"
"version_requirement": ">= 7.0.0 < 9.0.0"
}
],
"tags": [
"kdump"
],
"pdk-version": "2.1.0",
"pdk-version": "2.7.1",
"template-url": "https://github.com/treydock/pdk-templates#master",
"template-ref": "heads/master-0-g3b13f94"
"template-ref": "heads/master-0-g76f4dbb"
}
15 changes: 9 additions & 6 deletions spec/acceptance/kdump_spec.rb
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
# frozen_string_literal: true

require 'spec_helper_acceptance'

describe 'kdump class:' do
let(:pp) do
<<-EOS
<<-PP
# Set crashkernel variable because auto
# does not work in RAM < 1G which could
# happen in the hypervisor
class { 'kdump':
enable => true,
crashkernel => '128M'
}
EOS
PP
end

let(:pp_disable) do
<<-EOS
<<-PP
class { 'kdump': enable => false }
EOS
PP
end

hosts.each do |host|
context 'enable => true' do
context 'when enable => true' do
it 'runs successfully' do
# It will fail because kdump service can not start until after reboot.
apply_manifest_on(host, pp, catch_failures: false)
Expand Down Expand Up @@ -51,12 +53,13 @@ class { 'kdump': enable => false }
# end
end

context 'disable kdump' do
context 'when disable kdump' do
it 'runs successfully' do
apply_manifest_on(host, pp_disable, catch_failures: true)
host.reboot
sleep 60
end

it 'is idempotent' do
apply_manifest_on(host, pp_disable, catch_changes: true)
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ HOSTS:
- '/usr/sbin/init'
docker_image_commands:
- 'yum install -y wget which cronie iproute initscripts'
- 'wget --no-check-certificate https://copr.fedorainfracloud.org/coprs/jsynacek/systemd-backports-for-centos-7/repo/epel-7/jsynacek-systemd-backports-for-centos-7-epel-7.repo -O /etc/yum.repos.d/jsynacek-systemd-centos-7.repo'
- 'yum update -y systemd'
docker_env:
- LANG=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ HOSTS:
- agent
platform: el-8-x86_64
hypervisor: docker
image: rockylinux/rockylinux:8
image: almalinux:8
docker_preserve_image: true
docker_cmd:
- '/usr/sbin/init'
docker_image_commands:
- 'dnf install -y dnf-utils'
- 'dnf config-manager --set-enabled powertools'
- 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks'
- 'dnf install -y wget which cronie iproute initscripts langpacks-en glibc-all-langpacks glibc-langpack-en cpio'
docker_env:
- LANG=en_US.UTF-8
- LANGUAGE=en_US.UTF-8
Expand Down
Loading

0 comments on commit 9393e56

Please sign in to comment.