Skip to content

Instantly share code, notes, and snippets.

@lehrblogger
Last active December 10, 2015 02:48
Show Gist options
  • Save lehrblogger/4370273 to your computer and use it in GitHub Desktop.
Save lehrblogger/4370273 to your computer and use it in GitHub Desktop.
Trying to figure out proper environment and cookbook attribute syntax for Chef
# In my environment json file:
"default_attributes": {
"source_dir": "/vagrant/source_dir"
},
# When I look in the list of attributes at https://manage.opscode.com/nodes/[node_name],
# I see the 'source_dir' attribute, so far so good.
# Then, in my cookbook's default.rb attributes file:
default['mycookbook']['dir'] = "#{default[:source_dir].to_s}/mycookbook"
# And then run a provision, it seems happy, but then looking back at
# https://manage.opscode.com/nodes/[node_name], I see the mycookbook attribute as a hash,
# but the 'dir' attribute has a value of "#<Chef::Node::Attribute:0x0000000295d088>/mycookbook",
# rather than "/vagrant/source_dir/mycookbook".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment