Created
May 8, 2015 16:25
-
-
Save samukasmk/32bdd95429e30c2b5c1c to your computer and use it in GitHub Desktop.
Example of support for Data bag encrypted on Chef
This file contains 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
# Example of support for Data bag encrypted on Chef | |
# By: Samuel Maciel Sampaio <samukasmk@gmail.com> | |
# get data_bag obj | |
search("my_data_bag_name", "id:my_data_bag_item_name").each do |my_data_bag_obj| | |
# find for keys encrypted | |
key_found = my_data_bag_obj.keys.select{ |k| k != "id" }[0] | |
# if exists some key and its encrypted, reassing the data_bag obj | |
if key_found and my_data_bag_obj[key_found].include? 'encrypted_data' | |
my_data_bag_obj = Chef::EncryptedDataBagItem.load("my_data_bag_name", "my_data_bag_item_name") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment