I have a chef script that want to read the value of a file.
http_request "create repo" do
action :post
url "http://chef.sparqlr.net:8080/openrdf-sesame/repositories/SYSTEM/statements?context=%3Curn:x-local:graph1%3E&baseURI=%3Curn:x-local:graph1%3E"
headers "Content-Type" => "application/x-trig"
message *<Read in content for a file>*
end
I would like the message of the post coming from a file, can anyone advise what the syntax should be? I have try a few option, with ruby block etc but no luck. Many thanks!
You can use standard ruby classes to read a file, but as Chef has it's own File class you hav to prefix it with
::
to use the ruby class and not the Chef one.In case the source file is deployed via chef you can wrap the File.read in a lazy block so it will be executed only when the provider is called.
Example: