Skip to content

Instantly share code, notes, and snippets.

@ffrank
Created August 20, 2014 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ffrank/c9037239ae723264e9b6 to your computer and use it in GitHub Desktop.
Save ffrank/c9037239ae723264e9b6 to your computer and use it in GitHub Desktop.
Accessing the caller from a Puppet parser function
class demo::volatile {
demo::volatile_res { 'demo': }
}
define demo::volatile_res {
$result = volatile_function($name)
notify { $result: }
}
$ puppet apply -e 'include demo::volatile'
Error: Demo::Volatile_res[demo]: an error happened at /home/ffrank/.puppet/modules/demo/manifests/init.pp:21 on node geras.localdomain
Wrapped exception:
Demo::Volatile_res[demo]: an error happened
module Puppet::Parser::Functions
newfunction(:volatile_function, :type => :rvalue) do |args|
raise "#{@resource.ref}: an error happened"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment