Skip to content

Instantly share code, notes, and snippets.

@vitobotta
Forked from matschaffer/create_data_bag.rb
Created August 20, 2013 09:11
Show Gist options
  • Save vitobotta/6279100 to your computer and use it in GitHub Desktop.
Save vitobotta/6279100 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