Created
January 31, 2011 22:02
-
-
Save bakins/804922 to your computer and use it in GitHub Desktop.
brain dead data bags in chef solo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.nil? && @solo_data_bags[bag]) | |
@solo_data_bags[bag][item] | |
end | |
end | |
end | |
end | |
end |
On May 4, 2011, at 1:00 AM, matthewrudy wrote:
Thank you.
We've stolen this for our own chef solo switch.
Seems to work.
Enjoy ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you.
We've stolen this for our own chef solo switch.
Seems to work.
I added this code to a file called "data_bag_hack.rb"
then set my solo.rb to the following;