feat: initial commit

This commit is contained in:
root 2025-04-01 17:40:03 +00:00
commit 2dfb19d1a1
457 changed files with 40577 additions and 0 deletions

View file

@ -0,0 +1,18 @@
# This function returns either a rendered template or a deferred function to render at runtime.
# If any of the values in the variables hash are deferred, then the template will be deferred.
#
# Note: this function requires all parameters to be explicitly passed in. It cannot expect to
# use facts, class variables, and other variables in scope. This is because when deferred, we
# have to explicitly pass the entire scope to the client.
#
function stdlib::deferrable_epp(String $template, Hash $variables) >> Variant[String, Sensitive[String], Deferred] {
if $variables.stdlib::nested_values.any |$value| { $value.is_a(Deferred) } {
Deferred(
'inline_epp',
[find_template($template).file, $variables],
)
}
else {
epp($template, $variables)
}
}

View file

@ -0,0 +1,33 @@
# @summary function to cast ensure parameter to resource specific value
#
# @return [String]
function stdlib::ensure(
Variant[Boolean, Enum['present', 'absent']] $ensure,
Optional[Enum['directory', 'link', 'mounted', 'service', 'file', 'package']] $resource = undef,
) >> String {
$_ensure = $ensure ? {
Boolean => $ensure.bool2str('present', 'absent'),
default => $ensure,
}
case $resource {
'package': {
$_ensure ? {
'present' => 'installed',
default => 'absent',
}
}
'service': {
$_ensure ? {
'present' => 'running',
default => 'stopped',
}
}
undef: { $_ensure }
default: {
$_ensure ? {
'present' => $resource,
default => $_ensure,
}
}
}
}

View file

@ -0,0 +1,11 @@
# @summary This function is deprecated. It implements the functionality of the original non-namespaced stdlib `time` function.
#
# It is provided for compatability, but users should use the native time related functions directly.
#
# @param _timezone
# This parameter doesn't do anything, but exists for compatability reasons
function stdlib::time(Optional[String] $_timezone = undef) >> Integer {
# Note the `timezone` parameter doesn't do anything and didn't in the ruby implementation for _years_ (pre 1.8.7 perhaps ???)
deprecation('time', 'The stdlib `time` function is deprecated. Please direcly use native Puppet functionality instead. eg. `Integer(Timestamp().strftime(\'%s\'))`', false)
Integer(Timestamp().strftime('%s'))
}