[chef] Re: Re: Automate the attributes used in chef


Chronological Thread 
  • From: Walter Dolce < >
  • To:
  • Subject: [chef] Re: Re: Automate the attributes used in chef
  • Date: Tue, 22 Jul 2014 17:24:36 +0100

How would you deal complex nested attribute trees, conditions, comments, etc?

I'm not currently very experienced in Chef yet but this idea smells a bit to me. 
Would be nice to hear from experienced folks.


On 22 July 2014 15:25, Mark Harrison < " target="_blank"> > wrote:
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.

§