how to get the name of a defined resource inside itself?

asked 2017-01-02 09:11:35 -0500

Is there any way to find the actual name (i.e., not $name or $title) of a defined resource from inside its code?

# this file is in modules/mymodule/manifests/mydefine.pp
define mymodule::mydefine {
  notice("this define is ${something}")

...and I want the notice to read "this define is mydefine" or "this define is mymodule::mydefine".

edit retag flag offensive close merge delete


AFAIK, there's only $module_name. This gives you “mymodule”. You primarily want the manifest name though (in this case “mydefine”). I'm afraid, there's no such variable. Workaround: You can define inside mydefine.pp a new variable $self = 'mydefine' and use that instead.

Kai Burghardt gravatar imageKai Burghardt ( 2017-01-02 18:03:54 -0500 )edit