On Tue, Nov 13, 2012 at 5:25 AM, woosley. xu. <[email protected]> wrote: > I am thinking about loading some paramters from a external file for my > souces. Eg, > > class test { > > ## set parameters. > load_from_yaml("puppet:///modules/test/config.yaml") > }
Ah, cool idea. I think this would be a really valuable function to include in the stdlib [1] module. While it's very difficult to get the filesystem path, it seems like you really only need the contents of the file. If you have a puppet:// URI, you can speak to the Puppet fileserve using the REST API to get the file contents. This would avoid the need to read the file from disk yourself and it will work well even in multiple-master deployment scenarios since you're speaking to the API rather than to the underlying filesystem. The static compiler does just this. It reads the contents of the file using the FileServer API in the store_content method: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/indirector/catalog/static_compiler.rb#L160-161 You might be able to do something similar in your parser function. Given a URI, pass the string form to Puppet::FileServing::Content.indirection.find and you should get back a Ruby instance that models the file metadata and contains the content. Hope this helps, -Jeff [1] https://forge.puppetlabs.com/puppetlabs/stdlib -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
