Re: [Puppet Users] config files for ruby dsl manifests

Nan Liu
2011-09-06T15:56:42Z

On Tue, Sep 6, 2011 at 7:24 AM, Matt <mjblack@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