Puppet Function: debian::codename::compare
- Defined in:
- modules/debian/functions/codename/compare.pp
- Function type:
- Puppet Language
Summary
Test if the running debian codename against the codename passed using a specific operatorOverview
SPDX-License-Identifier: Apache-2.0
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'modules/debian/functions/codename/compare.pp', line 14
function debian::codename::compare (
String $codename,
Enum['==', '>=', '>', '<', '<=', '!='] $operator = '==',
Optional[String[1]] $compare_codename = undef,
) >> Boolean {
include debian
$valid_codenames = $debian::supported[$facts['os']['name']]
unless $codename in $valid_codenames {
fail("invalid codename (${codename}). supported codenames : ${valid_codenames.keys.join(', ')}")
}
if $compare_codename and !($compare_codename in $valid_codenames) {
fail("invalid codename (${compare_codename}). supported codenames : ${valid_codenames.keys.join(', ')}")
}
$major = $compare_codename ? {
undef => $debian::major,
default => $valid_codenames[$compare_codename],
}
$operator ? {
'>=' => $major >= $valid_codenames[$codename],
'>' => $major > $valid_codenames[$codename],
'<=' => $major <= $valid_codenames[$codename],
'<' => $major < $valid_codenames[$codename],
'!=' => $major != $valid_codenames[$codename],
default => $major == $valid_codenames[$codename],
}
}
|