From 1cbc931a6d80405a4c3bd88d57c0de5c0ea3e541 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 3 Aug 2010 09:14:35 -0700 Subject: [PATCH] Run chef provisioners with "-E" flag on sudo so PATH is preserved on CentOS [closes GH-133] --- CHANGELOG.md | 2 ++ lib/vagrant/provisioners/chef_server.rb | 2 +- lib/vagrant/provisioners/chef_solo.rb | 2 +- test/vagrant/provisioners/chef_server_test.rb | 2 +- test/vagrant/provisioners/chef_solo_test.rb | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 823d91abd..d6825356e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## 0.5.2 (unreleased) + - Sudo uses "-E" flag to preserve environment for chef provisioners. + This fixes issues with CentOS. [GH-133] - Added "IdentitiesOnly yes" to options when `vagrant ssh` is run to avoid "Too Many Authentication Failures" error. [GH-131] - Fix regression with `package` not working. [GH-132] diff --git a/lib/vagrant/provisioners/chef_server.rb b/lib/vagrant/provisioners/chef_server.rb index ed5f6c39c..b4677c0c6 100644 --- a/lib/vagrant/provisioners/chef_server.rb +++ b/lib/vagrant/provisioners/chef_server.rb @@ -48,7 +48,7 @@ module Vagrant end def run_chef_client - command = "cd #{env.config.chef.provisioning_path} && sudo chef-client -c client.rb -j dna.json" + command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json" logger.info "Running chef-client..." vm.ssh.execute do |ssh| diff --git a/lib/vagrant/provisioners/chef_solo.rb b/lib/vagrant/provisioners/chef_solo.rb index 473c5b8bb..5def9a142 100644 --- a/lib/vagrant/provisioners/chef_solo.rb +++ b/lib/vagrant/provisioners/chef_solo.rb @@ -38,7 +38,7 @@ module Vagrant end def run_chef_solo - command = "cd #{env.config.chef.provisioning_path} && sudo chef-solo -c solo.rb -j dna.json" + command = "cd #{env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json" logger.info "Running chef-solo..." vm.ssh.execute do |ssh| diff --git a/test/vagrant/provisioners/chef_server_test.rb b/test/vagrant/provisioners/chef_server_test.rb index 4957bf0e5..c6bd7411d 100644 --- a/test/vagrant/provisioners/chef_server_test.rb +++ b/test/vagrant/provisioners/chef_server_test.rb @@ -169,7 +169,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase end should "cd into the provisioning directory and run chef client" do - @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 -E chef-client -c client.rb -j dna.json").once @action.run_chef_client end diff --git a/test/vagrant/provisioners/chef_solo_test.rb b/test/vagrant/provisioners/chef_solo_test.rb index 80ffcacc4..dd7b37d8d 100644 --- a/test/vagrant/provisioners/chef_solo_test.rb +++ b/test/vagrant/provisioners/chef_solo_test.rb @@ -184,7 +184,7 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase end should "cd into the provisioning directory and run chef solo" do - @ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo chef-solo -c solo.rb -j dna.json").once + @ssh.expects(:exec!).with("cd #{@env.config.chef.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json").once @action.run_chef_solo end