Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created October 23, 2013 14:46
Show Gist options
  • Save mlafeldt/7120176 to your computer and use it in GitHub Desktop.
Save mlafeldt/7120176 to your computer and use it in GitHub Desktop.
Vagrantfile which loads Chef attributes from a JSON file
# If you want to provide custom Chef attributes that should not end up in Git
# (e.g. secret tokens), copy `chef.json.example` to `chef.json` and edit the
# latter accordingly (in that case, the example file will be ignored).
# ...
# Configure Chef Solo provisioner
config.vm.provision :chef_solo do |chef|
# Tell Vagrant where the cookbooks are located
chef.cookbooks_path = "vendor/cookbooks"
# Load node attributes and run list from a JSON file
json_file = %w(chef.json chef.json.example).select { |f| File.exists? f }.first
chef.json = JSON.parse(IO.read(json_file))
# Set Chef log level
chef.log_level = ENV.fetch("CHEF_LOG", "info").downcase.to_sym
end
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment