Puppet Function: os_version_gte

Defined in:
modules/stdlib/lib/puppet/functions/os_version_gte.rb
Function type:
Ruby 4.x API

Overview

os_version_gte(String[1] $os, String[1] $version)Boolean

> Note: Only the major version is taken into account.

Examples:

Example usage:#

if os_version_gte('Debian', '9') { }
if os_version_gte('Ubuntu', '18.04') { }

Parameters:

Returns:

  • (Boolean)

    `true` or `false



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'modules/stdlib/lib/puppet/functions/os_version_gte.rb', line 9

Puppet::Functions.create_function(:os_version_gte) do
  # @param os operating system
  # @param version
  #
  # @return [Boolean] `true` or `false
  dispatch :os_version_gte do
    param 'String[1]', :os
    param 'String[1]', :version
    return_type 'Boolean'
  end

  def os_version_gte(os, version)
    facts = closure_scope['facts']
    (facts['operatingsystem'] == os &&
     Puppet::Util::Package.versioncmp(version, facts['operatingsystemmajrelease']) >= 0)
  end
end