Created
September 24, 2014 23:46
-
-
Save dmerrick/f3e19870e5be7a4ee567 to your computer and use it in GitHub Desktop.
Use encrypted data bags without chef
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # this is a proof-of-concept for reading encrypted data bags | |
| # from a ruby script. you only need chef to be installed. | |
| require 'rubygems' | |
| require 'chef/rest' | |
| require 'chef/encrypted_data_bag_item' | |
| # prevent chef from trying to contact a server | |
| Chef::Config[:solo] = true | |
| # set up location of your data | |
| Chef::Config[:data_bag_path] = './chef/data_bags' | |
| Chef::Config[:encrypted_data_bag_secret] = './chef/data_bags/encrypted_data_bag_secret' | |
| # just using newrelic as an example here | |
| data = Chef::EncryptedDataBagItem.load('credentials', 'newrelic') | |
| puts data['license_key'] | |
| # => "9c395..." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment