Skip to content

Instantly share code, notes, and snippets.

@uran1980
Forked from matschaffer/create_data_bag.rb
Created July 26, 2013 19:39
Show Gist options
  • Save uran1980/6091679 to your computer and use it in GitHub Desktop.
Save uran1980/6091679 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('data_bag_key')
data = {"id" => "mysql", "root" => "some secret password"}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
FileUtils.mkpath('data_bags/passwords')
File.open('data_bags/passwords/mysql.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