[chef] Re: Re: Data bag implementation for chef-solo


Chronological Thread 
  • From: Miquel Torres < >
  • To:
  • Subject: [chef] Re: Re: Data bag implementation for chef-solo
  • Date: Wed, 2 Feb 2011 10:40:13 +0100
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=h5NVLWTthiyzfZ2MeMtUB+jxKYMDgfX2410Oxl/3h378Fp16VNLp/7tIS3Sca75dwb /IVEws38u1QfWSUZU7T3xub6QuSafT0iTkXE7k2IX0kk36viZTXjySZMnrztecfENGT/ wf1dKIC+37pW/q3nleByxB0RvEkSLXvctdUgw=

Yeah, it would be great to get this into Chef!


2011/2/1 Adam Jacob 
< >:
> Feel free to file a ticket and patch Chef if this is useful for you.
>
> Adam
>
> On Tue, Feb 1, 2011 at 7:42 AM, Brian Akins 
> < >
>  wrote:
>> We often use chef-solo for quick testing, etc.  This is our extremely 
>> simple
>> implementation of data bags for chef-solo.  Add "data_bag_path
>> /some/dir/data_bags" to your solo.rb and add this into your libraries:
>>
>> if Chef::Config[:solo]
>>   class Chef
>>     module Mixin
>>       module Language
>>
>>         def data_bag(bag)
>>           @solo_data_bags = {} if @solo_data_bags.nil?
>>           unless @solo_data_bags[bag]
>>             @solo_data_bags[bag] = {}
>>             Dir.glob(File.join(Chef::Config[:data_bag_path], bag,
>>                                "*.json")).each do |f|
>>               item = JSON.parse(IO.read(f))
>>               @solo_data_bags[bag][item['id']] = item
>>             end
>>           end
>>           @solo_data_bags[bag].keys
>>         end
>>
>>         def data_bag_item(bag, item)
>>           data_bag(bag) unless 
>> (
>>  &&
>> @solo_data_bags[bag])
>>           @solo_data_bags[bag][item]
>>         end
>>
>>       end
>>     end
>>   end
>> end
>>
>>
>> I'm an old school C guy and I blame most of the code on a co-worker ;)  Use
>> at your own risk, will probably eat your hard drive, etc.
>>
>> --Brian
>>
>
>
>
> --
> Opscode, Inc.
> Adam Jacob, Chief Product Officer
> T: (206) 619-7151 E: 
> 
>



Archive powered by MHonArc 2.6.16.

§