Puppet Function: debian::codename::require

Defined in:
modules/debian/functions/codename/require.pp
Function type:
Puppet Language

Summary

fail to compile if the running debian codename against the codename passed using a specific operator.

Overview

debian::codename::require(String $codename, Enum['==', '>=', '>', '<', '<=', '!='] $operator = '==', Optional[String] $msg = undef)Boolean

SPDX-License-Identifier: Apache-2.0

Examples:

Assuming theses functions are compiled for a host running debian buster then

debian::codename::require('buster')  # pass/no action
debian::codename::compare('stretch') # fail()
debian::codename::compare('stretch', '<') # fail()
debian::codename::compare('stretch', '>') # pass/no action
debian::codename::compare('buster', '>=') # pass/no action
debian::codename::compare('buster', '<=') # pass/no action

Parameters:

  • codename (String)

    the codename you want to test against

  • operator (Enum['==', '>=', '>', '<', '<=', '!=']) (defaults to: '==')

    the comparison operator to us i.e

  • msg (Optional[String]) (defaults to: undef)

Returns:

  • (Boolean)

    result of the comparison



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'modules/debian/functions/codename/require.pp', line 13

function debian::codename::require (
    String                                 $codename,
    Enum['==', '>=', '>', '<', '<=', '!='] $operator = '==',
    Optional[String]                       $msg      = undef,
) {
    unless debian::codename::compare($codename, $operator) {
        $_msg = $msg ? {
            undef   => "node codename does not meet requirement `${debian::codename()} ${operator} ${codename}`",
            default => $msg,
        }
        fail($_msg)
    }
}