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. On Sep 6, 11:56 am, Nan Liu <n...@puppetlabs.com> wrote: > On Tue, Sep 6, 2011 at 7:24 AM, Matt <mjbl...@gmail.com> wrote: > > I know I brought this up in a different post a while ago in as a > > different question. > > > Whats the best way to locate a configuration file from a ruby > > manifest? I'm tring to load a yaml for database properties but so far > > the only way to make it work is if I explicitly define a path either > > manually or looking up a specific module path. The latter being an > > issue if the module name is not known when it is installed. > > Not sure if there's an exposed API that's more suitable. What are you > using currently for find the file in a specific module? > > I'm not sure why the module name is unknown, unless you are planning > to allow someone to change it during installation. Similar to puppet > manifests you should be able to use the puppet variable $module_name > if you are on 2.6+. Since the files directory is intended for file > service, the best place for the config is probably the templates > directory. The following should return the fully qualified filepath to > the config file in the module templates dir: > > Puppet::Parser::Files.find_template_in_module("#{scope.lookup_var('module_name')}/config.yaml") > > 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.