Is there a way to load a file from within the module in Ruby DSL? The idea I have is to load a file similar to like how template works. I''m trying to read in a database properties file and I would like to keep within the module instead of hard coding paths. -- 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.
Scott Smith
2011-Jul-26 04:16 UTC
Re: [Puppet Users] ruby dsl, loading files from within the modules
Sounds like a good use case for writing a custom fact. On Mon, Jul 25, 2011 at 5:09 PM, Matt <mjblack@gmail.com> wrote:> Is there a way to load a file from within the module in Ruby DSL? > > The idea I have is to load a file similar to like how template works. > > I''m trying to read in a database properties file and I would like to > keep within the module instead of hard coding paths. > > -- > 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. > >-- 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.
Matt
2011-Jul-26 14:10 UTC
[Puppet Users] Re: ruby dsl, loading files from within the modules
I''m all for writing facts but I dont think it is the best solution in this given problem. You can easily create a variable at top level to identify where the file is and use it but that is not really elegant either. With file definitions I can use the template function to read in from a module but it doesnt seem to be working for me in outside of the file resource. On Jul 26, 12:16 am, Scott Smith <sc...@ohlol.net> wrote:> Sounds like a good use case for writing a custom fact. > > > > On Mon, Jul 25, 2011 at 5:09 PM, Matt <mjbl...@gmail.com> wrote: > > Is there a way to load a file from within the module in Ruby DSL? > > > The idea I have is to load a file similar to like how template works. > > > I''m trying to read in a database properties file and I would like to > > keep within the module instead of hard coding paths. > > > -- > > 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.- Hide quoted text - > > - Show quoted text --- 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.
Nan Liu
2011-Jul-26 14:46 UTC
Re: [Puppet Users] ruby dsl, loading files from within the modules
On Mon, Jul 25, 2011 at 8:09 PM, Matt <mjblack@gmail.com> wrote:> Is there a way to load a file from within the module in Ruby DSL? > > The idea I have is to load a file similar to like how template works. > > I''m trying to read in a database properties file and I would like to > keep within the module instead of hard coding paths.Not sure if there''s a better way: mod = Puppet::Module.find(''module_name'') mod.path> mod = Puppet::Module.find(''motd'') > mod.path=> "/etc/puppetlabs/puppet/modules/motd" 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Matt
2011-Jul-26 16:10 UTC
[Puppet Users] Re: ruby dsl, loading files from within the modules
I''ll have to check that out that does seem to look a little better
what I figured out before.
What I did was this, which is just a different way.
db_props
Puppet::Module.modulepath(scope.lookupvar("environment")).to_s +
''/
module_name/conf/db.yaml''
On Jul 26, 10:46 am, Nan Liu <n...@puppetlabs.com>
wrote:> On Mon, Jul 25, 2011 at 8:09 PM, Matt <mjbl...@gmail.com> wrote:
> > Is there a way to load a file from within the module in Ruby DSL?
>
> > The idea I have is to load a file similar to like how template works.
>
> > I''m trying to read in a database properties file and I would
like to
> > keep within the module instead of hard coding paths.
>
> Not sure if there''s a better way:
>
> mod = Puppet::Module.find(''module_name'')
> mod.path
>
> > mod = Puppet::Module.find(''motd'')
> > mod.path
>
> => "/etc/puppetlabs/puppet/modules/motd"
>
> 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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.