Quantcast
Channel: Ask Puppet: Puppet DevOps Q&A Community - RSS feed
Viewing all articles
Browse latest Browse all 6104

How do I resolve a file reference via Ruby in a custom module

$
0
0
Hi everyone, I have what I think should be a simple question, but for the life of me just can't find a solution. Hoping you can help, here goes... I'm trying to build a custom module that makes a couple of quick REST calls (I know, kind of "unpuppety"). I've got everything up and running, except for I can't figure out how to read the contents of a "puppetted" file reference from Ruby. In the below resource declaration, I have hardcoded the location of a file that lives inside of my module. This works just fine for my testing, but is not adequate when run on my server. elasticsearch_template { 'analytic_template': ensure => present, servername => 'localhost', port => '9201', ssl => false, content => 'C:\Users\specnik\repos\elasticsearch\files\template_1.json' # content => 'puppet:///modules/elasticsearch/template_1.json', } What I think best practice would be is to reference a file from within a module like I have in the commented line above. The question is, with that type of reference, how do I read the file from Ruby? Right now I am using the following, which works for the hard coded file reference only: Puppet::FileSystem.read(resource[:content]) Surely there must be an API to sort this kind of thing out?? Has anybody come across this type of thing before and could point me to a solution? Oh, and the reason I am not using an existing elasticsearch module is because I am spinning up a container with elasticsearch and not trying to install directly on the machine. Thanks! Scott

Viewing all articles
Browse latest Browse all 6104

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>