Created
August 20, 2014 21:41
-
-
Save ffrank/c9037239ae723264e9b6 to your computer and use it in GitHub Desktop.
Accessing the caller from a Puppet parser function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class demo::volatile { | |
demo::volatile_res { 'demo': } | |
} | |
define demo::volatile_res { | |
$result = volatile_function($name) | |
notify { $result: } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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