Mercurial > repos > other > Puppet
annotate modules/stdlib/lib/puppet/functions/os_version_gte.rb @ 424:4a2ee7e3b110
Update stdlib in case it fixed deprecation
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 09 Oct 2022 10:34:32 +0100 |
parents | d9352a684e62 |
children | adf6fe9bbc17 |
rev | line source |
---|---|
275
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
1 # @summary |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 # Checks if the OS version is at least a certain version. |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
3 # > *Note:* |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 # Only the major version is taken into account. |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 # |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 # @example Example usage:# |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 # if os_version_gte('Debian', '9') { } |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 # if os_version_gte('Ubuntu', '18.04') { } |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 Puppet::Functions.create_function(:os_version_gte) do |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 # @param os operating system |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 # @param version |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
12 # |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
13 # @return [Boolean] `true` or `false |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
14 dispatch :os_version_gte do |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
15 param 'String[1]', :os |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
16 param 'String[1]', :version |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
17 return_type 'Boolean' |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
18 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
19 |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
20 def os_version_gte(os, version) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
21 facts = closure_scope['facts'] |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 (facts['operatingsystem'] == os && |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 Puppet::Util::Package.versioncmp(version, facts['operatingsystemmajrelease']) >= 0) |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 end |
d9352a684e62
Mass update of modules to remove deprecation warnings
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 end |