diff --git a/lib/vagrant/provisioners/chef.rb b/lib/vagrant/provisioners/chef.rb index 6e3a575df..675a450d1 100644 --- a/lib/vagrant/provisioners/chef.rb +++ b/lib/vagrant/provisioners/chef.rb @@ -11,6 +11,7 @@ module Vagrant attr_accessor :validation_key_path attr_accessor :validation_client_name attr_accessor :client_key_path + attr_accessor :node_name # Chef solo specific config attr_accessor :cookbooks_path @@ -22,6 +23,7 @@ module Vagrant def initialize @validation_client_name = "chef-validator" @client_key_path = "/etc/chef/client.pem" + @node_name = "client" @cookbooks_path = "cookbooks" @provisioning_path = "/tmp/vagrant-chef" @@ -99,4 +101,4 @@ module Vagrant end end end -end \ No newline at end of file +end diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index 7f7053600..e29908db2 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -64,7 +64,7 @@ solo def run_chef_client logger.info "Running chef-client..." env.ssh.execute do |ssh| - ssh.exec!("cd #{env.config.chef.provisioning_path} && sudo chef-client -c client.rb -j dna.json") do |channel, data, stream| + ssh.exec!("cd #{env.config.chef.provisioning_path} && sudo chef-client -c client.rb -j dna.json -N #{env.config.chef.node_name}") do |channel, data, stream| # TODO: Very verbose. It would be easier to save the data and only show it during # an error, or when verbosity level is set high logger.info("#{stream}: #{data}") @@ -81,4 +81,4 @@ solo end end end -end \ No newline at end of file +end diff --git a/test/test_helper.rb b/test/test_helper.rb index ba780bff7..98c3dc5b5 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -51,6 +51,7 @@ class Test::Unit::TestCase config.chef.chef_server_url = "http://localhost:4000" config.chef.validation_key_path = "validation.pem" config.chef.client_key_path = "/zoo/foo/bar.pem" + config.chef.node_name = "baz" config.chef.cookbooks_path = "cookbooks" config.chef.provisioning_path = "/tmp/vagrant-chef" config.chef.json = { diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index d2008dfab..42a7365a1 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -179,7 +179,7 @@ config context "running chef client" do should "cd into the provisioning directory and run chef client" do ssh = mock("ssh") - ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo chef-client -c client.rb -j dna.json").once + ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo chef-client -c client.rb -j dna.json -N #{@env.config.chef.node_name}").once @env.ssh.expects(:execute).yields(ssh) @action.run_chef_client end