2 # Checks if the OS version is at least a certain version.
4 # Only the major version is taken into account.
6 # @example Example usage:#
7 # if os_version_gte('Debian', '9') { }
8 # if os_version_gte('Ubuntu', '18.04') { }
9 Puppet::Functions.create_function(:os_version_gte) do
10 # @param os operating system
13 # @return [Boolean] `true` or `false
14 dispatch :os_version_gte do
15 param 'String[1]', :os
16 param 'String[1]', :version
20 def os_version_gte(os, version)
21 facts = closure_scope['facts']
22 (facts['operatingsystem'] == os &&
23 Puppet::Util::Package.versioncmp(version, facts['operatingsystemmajrelease']) >= 0)