A simple way would be to write a script that would read the json file
and generate an attributes file that you can put in place. Something
like the following would work:
#!/usr/bin/env ruby
require 'json'
data = "JSON.parse(File.read(ARGV[0]))
data.each { |k, v| puts "default['cookbookname']['#{k}'] = '#{v}'" }
Change cookbookname as appropriate. And this assumes the json file is
a simple set of key value pairs. This prints out the file contents so
you would want to run it as 'myscript.rb >
cookbookname/attributes/default.rb', or you could change the script to
write out the attributes file directly.
Regards,
Mark
On Tue, Jul 22, 2014 at 2:12 AM, < "> > wrote:
> Hi
>
> I want to automate the attributes file (default.rb) inside the cookbook. I have
> a .json file (which is generated by another tool), with the details of the
> attribute values that should be given to the cookbook. Please suggest me the
> best method to achieve this goal.
>
> Thank you.
walter dolce | developer
twitter @walterdolce
skype walter.dolce
tel +39 (0) 327 597 9830
Archive powered by MHonArc 2.6.16.