luke.bigum
2011-Jan-11 15:06 UTC
[Puppet Users] Access parent resource name and type inside a template
Hi all, A question for those familiar with the internal Puppet APIs: is it possible to access the name and type of the Puppet resource/define that "called" a template from within that template? There was talk on the list a year ago that mentions "scope.compiler.catalog.vertices", but this is a list of all Puppet resources where I just want the one ''current'' one, or even better, the ability to determine the parent resource/define of this resource/define (and up and up the chain). It goes against information hiding principles, but it might be nice to say "this bit of this file was generated by this Puppet resource". Thanks, -Luke -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Stefan Schulte
2011-Jan-11 17:53 UTC
Re: [Puppet Users] Access parent resource name and type inside a template
On Tue, Jan 11, 2011 at 07:06:59AM -0800, luke.bigum wrote:> Hi all, > > A question for those familiar with the internal Puppet APIs: is it > possible to access the name and type of the Puppet resource/define > that "called" a template from within that template? There was talk on > the list a year ago that mentions "scope.compiler.catalog.vertices", > but this is a list of all Puppet resources where I just want the one > ''current'' one, or even better, the ability to determine the parent > resource/define of this resource/define (and up and up the chain). > > It goes against information hiding principles, but it might be nice to > say "this bit of this file was generated by this Puppet resource". > > Thanks, > > -LukeThis was mostly done by try and error since I dont know what you can access through scope.* and what they mean but it worked in a short test: # This file was generated by puppet # # Template Sourcefile: <%= file %> # Puppetmanifest : <%= scope.source.file %> # Class/Define : <%= scope.resource.path %> -Stefan