Skip to content

Instantly share code, notes, and snippets.

@jtimberman
Created March 20, 2012 05:46
Show Gist options
  • Save jtimberman/2131761 to your computer and use it in GitHub Desktop.
Save jtimberman/2131761 to your computer and use it in GitHub Desktop.
Read in the knife.rb configuration to pass into the Vagrant chef-client provisioner
require 'chef'
require 'chef/config'
require 'chef/knife'
current_dir = File.dirname(__FILE__)
Chef::Config.from_file(File.join(current_dir, '.chef', 'knife.rb'))
Vagrant::Config.run do |config|
config.vm.provision :chef_client do |chef|
chef.chef_server_url = Chef::Config[:chef_server_url]
chef.validation_key_path = "#{current_dir}/.chef/#{Chef::Config[:validation_client_name]}.pem"
chef.validation_client_name = Chef::Config[:validation_client_name]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment