Skip to content

Commit

Permalink
refactor legacy facts to add compatibility with puppet 8
Browse files Browse the repository at this point in the history
  • Loading branch information
vchepkov authored and ekohl committed Jan 31, 2023
1 parent c51f7a1 commit 16de95c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifests/current.pp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
require => Package[$package_name],
}

if versioncmp($::operatingsystemrelease, '7.0') >= 0 {
if versioncmp($facts['os']['release']['full'], '7.0') >= 0 {
file { [
"/etc/cron.weekly/${package_name}",
"/etc/cron.daily/${package_name}",
Expand Down
4 changes: 2 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
if $deployment_style {
$class_name = $deployment_style
} else {
if (versioncmp($::operatingsystemrelease, '6.10') < 0 or
(versioncmp($::operatingsystemrelease, '7.0') >= 0 and versioncmp($::operatingsystemrelease, '7.5') < 0)) {
if (versioncmp($facts['os']['release']['full'], '6.10') < 0 or
(versioncmp($facts['os']['release']['full'], '7.0') >= 0 and versioncmp($facts['os']['release']['full'], '7.5') < 0)) {
$class_name = 'old'
} else {
$class_name = 'current'
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/current_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe 'access_insights_client::current' do
context 'on 6.10' do
let :facts do
{:operatingsystemrelease => '6.10'}
{os: {release: {full: '6.10'}}}
end

it { is_expected.to compile.with_all_deps }
Expand All @@ -21,7 +21,7 @@

context 'on 7.0' do
let :facts do
{:operatingsystemrelease => '7.0'}
{os: {release: {full: '7.0'}}}
end

it { is_expected.to compile.with_all_deps }
Expand Down
4 changes: 2 additions & 2 deletions spec/classes/init_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
end

let :facts do
{:operatingsystemrelease => '6.10'}
{os: {release: {full: '6.10'}}}
end

it { is_expected.to compile.with_all_deps }
Expand All @@ -26,7 +26,7 @@
}.each do |version, expected|
context "on #{version}" do
let :facts do
{:operatingsystemrelease => version}
{os: {release: {full: version}}}
end

it { is_expected.to compile.with_all_deps }
Expand Down

0 comments on commit 16de95c

Please sign in to comment.