Skip to content

Instantly share code, notes, and snippets.

@kgorskowski
Created March 19, 2015 22:50
Show Gist options
  • Save kgorskowski/185f63c22c45efe5159b to your computer and use it in GitHub Desktop.
Save kgorskowski/185f63c22c45efe5159b to your computer and use it in GitHub Desktop.
create encrypted data bags for chef manually
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('chef_secret')
data = {"id" => "name_of_secret_goes_here", "key" => 'secret_goes_here'}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/name_of_secret_goes_here.json', 'w') do |f|
f.print encrypted_data.to_json
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment