I am using 2.6.6, when I try your example I get a empty string back, I tried with 'module_name' and the actual name of the module and both return an empty string.
On Sep 6, 12:27 pm, Nan Liu <n...@puppetlabs.com> wrote: > On Tue, Sep 6, 2011 at 9:08 AM, Matt <mjbl...@gmail.com> wrote: > > I'm trying to write a ruby dsl manifest that pulls data from a > > database. The issue I'm trying to overcome is I dont want to have to > > hardcode the location of the db configuration. If I set it at the > > init.pp level the configuration it will be picked up as top scope and > > dumped to the facts, and also be visible to other things like > > mcollective. > > > The piece of code you provided did not work for me, it looks like I'm > > not able to pull back the module name from scope it seems. > > What version of Puppet? > > Here's a full example with file path: > > # init.rb > hostclass :custom do > pmod = scope.lookupvar('module_name') > fpath = Puppet::Parser::Files.find_template_in_module("#{pmod}/config.yaml") > notify pmod, :message => pmod > notify fpath, :message => fpath > end > > Directory layout in modules: > > └── custom > ├── manifests > │ └── init.rb > ├── templates > │ └── config.yaml > └── tests > └── init.pp > > Sample output: > notice: custom > notice: /Stage[main]/Custom/Notify[custom]/message: defined 'message' > as 'custom' > notice: /Users/nan/.puppet/modules/custom/templates/config.yaml > notice: > /Stage[main]/Custom/Notify[/Users/nan/.puppet/modules/custom/templates/config.yaml]/message: > defined 'message' as > '/Users/nan/.puppet/modules/custom/templates/config.yaml' > notice: Finished catalog run in 0.04 seconds > > Thanks, > > Nan -- 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+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.