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
↧