Skip to content

Instantly share code, notes, and snippets.

@afirth afirth/gist:8829468
Last active Aug 29, 2015

What would you like to do?
def self.load(data_bag, name, secret = nil) #secret can be nil
raw_hash = Chef::DataBagItem.load(data_bag, name) #load the raw (encrypted) hash into a databag object
secret = secret || self.load_secret #if secret is specified, this or operator short circuits and returns the first value. if secret is nil, calls self.load secret (L7), secret) #return a new object
def self.load_secret(path=nil) #again, path can be nil
path ||= Chef::Config[:encrypted_data_bag_secret] # a shortcut to saying path = path || Chef::Config... as L3
if !path #nothing in path, means the default secret location wasn't set either. are you seeing this error?
raise ArgumentError, "No secret specified to load_secret and no secret found at #{Chef::Config.platform_specific_path('/etc/chef/encrypted_data_bag_secret')}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.