Skip to content

Instantly share code, notes, and snippets.

@mveitas
Created March 14, 2014 16:13
Show Gist options
  • Save mveitas/9550909 to your computer and use it in GitHub Desktop.
Save mveitas/9550909 to your computer and use it in GitHub Desktop.
Creating an Encrypted Data Bag File
require 'rubygems'
require 'chef/encrypted_data_bag_item'
secret = Chef::EncryptedDataBagItem.load_secret('~/encrypted_data_bag_secret')
data = {
'admins' => {
'administrator' => {
'db' => 'admin',
'password' => 'secret',
'read_only' => false
}
}, 'id' => 'mongo-users'
}
encrypted_data = Chef::EncryptedDataBagItem.encrypt_data_bag_item(data, secret)
File.open('~/mongo-users.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