Module: Chef::Sugar::DataBag
Instance Method Summary collapse
-
#encrypted_data_bag_item(bag, id) ⇒ Hash
Helper method for loading an encrypted data bag item in a similar syntax/recipe DSL method.
-
#encrypted_data_bag_item_for_environment(node, bag, id) ⇒ Hash
This algorithm attempts to find the data bag entry for the current node’s Chef environment.
Instance Method Details
#encrypted_data_bag_item(bag, id) ⇒ Hash
Helper method for loading an encrypted data bag item in a similar syntax/recipe DSL method.
33 34 35 36 |
# File 'lib/chef/sugar/data_bag.rb', line 33 def encrypted_data_bag_item(bag, id) Chef::Log.debug "Loading encrypted data bag item #{bag}/#{id}" Chef::EncryptedDataBagItem.load(bag, id) end |
#encrypted_data_bag_item_for_environment(node, bag, id) ⇒ Hash
This algorithm attempts to find the data bag entry for the current node’s Chef environment. If there are no environment-specific values, the “default” bucket is used. The data bag must follow the schema:
{
"default": {...},
"environment_name": {...},
"other_environment": {...},
}
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/chef/sugar/data_bag.rb', line 59 def encrypted_data_bag_item_for_environment(node, bag, id) data = encrypted_data_bag_item(bag, id) if data[node.chef_environment] Chef::Log.debug "Using #{node.chef_environment} as the key" data[node.chef_environment] else Chef::Log.debug "#{node.chef_environment} key does not exist, using `default`" data['default'] end end |