Permalink
Browse files

Merge pull request #7 from infospace/master

Encrypted data bag support
  • Loading branch information...
2 parents 6c1d0ed + d430fb1 commit 3ca36161924d16592871f7540ddae4558e93c740 @smith smith committed Jul 9, 2012
Showing with 12 additions and 1 deletion.
  1. +1 −1 capistrano-chef.gemspec
  2. +11 −0 lib/capistrano/chef.rb
@@ -20,5 +20,5 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
s.add_dependency 'capistrano', '>= 2'
- s.add_dependency 'chef', '>= 0.10.8'
+ s.add_dependency 'chef', '>= 0.10.10'
end
@@ -37,6 +37,10 @@ def self.get_data_bag_item(id, data_bag = :apps)
Chef::DataBagItem.load(data_bag, id).raw_data
end
+ def self.get_encrypted_data_bag_item(id, data_bag = :apps, secret = nil)
+ Chef::EncryptedDataBagItem.load(data_bag, id, secret).to_hash
+ end
+
# Load into Capistrano
def self.load_into(configuration)
self.configure_chef
@@ -52,6 +56,13 @@ def set_from_data_bag(data_bag = :apps)
set k, v
end
end
+
+ def set_from_encrypted_data_bag(data_bag = :apps, secret = nil)
+ raise ':application must be set' if fetch(:application).nil?
+ capistrano_chef.get_encrypted_data_bag_item(application, data_bag, secret).each do |k, v|
+ set k, v
+ end
+ end
end
end
end

0 comments on commit 3ca3616

Please sign in to comment.