diff --git a/lib/puppet/functions/os_version_gte.rb b/lib/puppet/functions/os_version_gte.rb index c0e004322..151c3c536 100644 --- a/lib/puppet/functions/os_version_gte.rb +++ b/lib/puppet/functions/os_version_gte.rb @@ -22,6 +22,6 @@ def os_version_gte(os, version) facts = closure_scope['facts'] (facts['operatingsystem'] == os && - Puppet::Util::Package.versioncmp(version, facts['operatingsystemmajrelease']) >= 0) + Puppet::Util::Package.versioncmp(facts['operatingsystemmajrelease'], version) >= 0) end end diff --git a/spec/functions/os_version_gte_spec.rb b/spec/functions/os_version_gte_spec.rb index 5de58384f..aec498270 100644 --- a/spec/functions/os_version_gte_spec.rb +++ b/spec/functions/os_version_gte_spec.rb @@ -11,9 +11,10 @@ } end + it { is_expected.to run.with_params('Debian', '10').and_return(false) } it { is_expected.to run.with_params('Debian', '9').and_return(true) } - it { is_expected.to run.with_params('Debian', '8').and_return(false) } - it { is_expected.to run.with_params('Debian', '8.0').and_return(false) } + it { is_expected.to run.with_params('Debian', '8').and_return(true) } + it { is_expected.to run.with_params('Debian', '8.0').and_return(true) } it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(false) } it { is_expected.to run.with_params('Fedora', '29').and_return(false) } end @@ -27,9 +28,11 @@ end it { is_expected.to run.with_params('Debian', '9').and_return(false) } - it { is_expected.to run.with_params('Ubuntu', '16').and_return(false) } + it { is_expected.to run.with_params('Ubuntu', '16').and_return(true) } + it { is_expected.to run.with_params('Ubuntu', '14.04').and_return(true) } it { is_expected.to run.with_params('Ubuntu', '16.04').and_return(true) } - it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(true) } + it { is_expected.to run.with_params('Ubuntu', '18.04').and_return(false) } + it { is_expected.to run.with_params('Ubuntu', '20.04').and_return(false) } it { is_expected.to run.with_params('Fedora', '29').and_return(false) } end