Skip to content

Instantly share code, notes, and snippets.

@h0tw1r3
Created January 2, 2023 19:13
Show Gist options
  • Save h0tw1r3/e80e5cf039f6598c3b14f15274277123 to your computer and use it in GitHub Desktop.
Save h0tw1r3/e80e5cf039f6598c3b14f15274277123 to your computer and use it in GitHub Desktop.
puppet custom functions
# Return a random number
Puppet::Functions.create_function(:rand) do
# @param [Integer] max
# maximum random number
# @return [Variant[Integer,Float]]
# random number
# @example Calling the function
# rand(10)
dispatch :generate_random_number do
optional_param 'Integer', :max
return_type 'Variant[Integer,Float]'
end
def generate_random_number(max = nil)
rand(max)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment