#!/opt/chef-workstation/embedded/bin/ruby require "chef/encrypted_data_bag_item" require "json" if ARGV.length != 2 puts "usage: decrypt_databag.rb /path/to/cipher_json_data_bag KEY" abort end cipherdata_path = ARGV[0] secret = ARGV[1] #secret = Chef::EncryptedDataBagItem.load_secret(ARGV[1]) encrypted_data = JSON.parse(File.read(cipherdata_path)) plain_data = Chef::EncryptedDataBagItem.new(encrypted_data, secret).to_hash puts JSON.pretty_generate(plain_data)