Puppet Function: stdlib::ensure

Defined in:
vendor_modules/stdlib/functions/ensure.pp
Function type:
Puppet Language

Overview

stdlib::ensure(Variant[Boolean, Enum['present', 'absent']] $ensure, Enum['directory', 'link', 'mounted', 'service', 'file', 'package'] $resource)String

Parameters:

  • ensure (Variant[Boolean, Enum['present', 'absent']])
  • resource (Enum['directory', 'link', 'mounted', 'service', 'file', 'package'])

Returns:



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'vendor_modules/stdlib/functions/ensure.pp', line 2

function stdlib::ensure(
    Variant[Boolean, Enum['present', 'absent']]               $ensure,
    Enum['directory', 'link', 'mounted', 'service', 'file', 'package'] $resource,
) >> String {
    $_ensure = $ensure ? {
        Boolean => $ensure.bool2str('present', 'absent'),
        default => $ensure,
    }
    case $resource {
        'package': {
            $_ensure ? {
                'present' => 'installed',
                default   => 'absent',
            }
        }
        'service': {
            $_ensure ? {
                'present' => 'running',
                default   => 'stopped',
            }
        }
        default: {
            $_ensure ? {
                'present' => $resource,
                default   => $_ensure,
            }
        }
    }
}