All provisioners are now RVM-friendly

This commit is contained in:
Mitchell Hashimoto 2011-01-12 16:57:19 -08:00
parent 93d241f4ce
commit 2a5070dad7
10 changed files with 27 additions and 35 deletions

View File

@ -10,11 +10,9 @@ module Vagrant
def verify_binary(binary)
vm.ssh.execute do |ssh|
ssh.shell do |sh|
# Checks for the existence of chef binary and error if it
# doesn't exist.
sh.execute("which #{binary}", :error_class => ChefError, :_key => :chef_not_detected, :binary => binary)
end
# Checks for the existence of chef binary and error if it
# doesn't exist.
ssh.exec!("sudo -i which #{binary}", :error_class => ChefError, :_key => :chef_not_detected, :binary => binary)
end
end

View File

@ -70,7 +70,7 @@ module Vagrant
end
def run_chef_client
command = "cd #{config.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json"
command = "sudo -i 'cd #{config.provisioning_path} && chef-client -c client.rb -j dna.json'"
env.ui.info I18n.t("vagrant.provisioners.chef.running_client")
vm.ssh.execute do |ssh|

View File

@ -60,7 +60,7 @@ module Vagrant
end
def run_chef_solo
command = "cd #{config.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json"
command = "sudo -i 'cd #{config.provisioning_path} && chef-solo -c solo.rb -j dna.json'"
env.ui.info I18n.t("vagrant.provisioners.chef.running_solo")
vm.ssh.execute do |ssh|

View File

@ -43,9 +43,7 @@ module Vagrant
def verify_binary(binary)
vm.ssh.execute do |ssh|
ssh.shell do |sh|
sh.execute("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
end
ssh.exec!("sudo -i which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
end
end
@ -75,11 +73,11 @@ module Vagrant
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
vm.ssh.execute do |ssh|
ssh.shell do |sh|
sh.execute "sudo -i 'cd #{config.pp_path}; puppet #{options}'" do |process|
process.on_output do |p, data|
env.ui.info(data)
end
ssh.exec! "sudo -i 'cd #{config.pp_path}; puppet #{options}'" do |ch, type, data|
if type == :exit_status
ssh.check_exit_status(data, command)
else
env.ui.info(data)
end
end
end

View File

@ -26,9 +26,9 @@ module Vagrant
def verify_binary(binary)
vm.ssh.execute do |ssh|
# Checks for the existence of puppetd binary and error if it
# doesn't exist.
ssh.exec!("which #{binary}", :error_class => PuppetServerError, :_key => :puppetd_not_detected, :binary => binary)
ssh.shell do |sh|
sh.execute("sudo -i which #{binary}", :error_class => PuppetServerError, :_key => :puppetd_not_detected, :binary => binary)
end
end
end
@ -41,14 +41,14 @@ module Vagrant
cn = env.config.vm.box
end
command = "sudo -E puppetd #{options} --server #{config.puppet_server} --certname #{cn}"
command = "sudo -i puppetd #{options} --server #{config.puppet_server} --certname #{cn}"
env.ui.info I18n.t("vagrant.provisioners.puppet_server.running_puppetd")
vm.ssh.execute do |ssh|
ssh.exec!(command) do |channel, type, data|
ssh.check_exit_status(data, command) if type == :exit_status
env.ui.info("#{data}: #{type}") if type != :exit_status
env.ui.info(data) if type != :exit_status
end
end
end

View File

@ -145,7 +145,7 @@ class ChefServerProvisionerTest < Test::Unit::TestCase
end
should "cd into the provisioning directory and run chef client" do
@ssh.expects(:exec!).with("cd #{@config.provisioning_path} && sudo -E chef-client -c client.rb -j dna.json").once
@ssh.expects(:exec!).with("sudo -i 'cd #{@config.provisioning_path} && chef-client -c client.rb -j dna.json'").once
@action.run_chef_client
end

View File

@ -206,7 +206,7 @@ class ChefSoloProvisionerTest < Test::Unit::TestCase
end
should "cd into the provisioning directory and run chef solo" do
@ssh.expects(:exec!).with("cd #{@config.provisioning_path} && sudo -E chef-solo -c solo.rb -j dna.json").once
@ssh.expects(:exec!).with("sudo -i 'cd #{@config.provisioning_path} && chef-solo -c solo.rb -j dna.json'").once
@action.run_chef_solo
end

View File

@ -111,14 +111,12 @@ class ChefProvisionerTest < Test::Unit::TestCase
context "verifying binary" do
setup do
@ssh = mock("ssh")
@shell = mock("shell")
@ssh.stubs(:shell).yields(@shell)
@vm.ssh.stubs(:execute).yields(@ssh)
end
should "verify binary exists" do
binary = "foo"
@shell.expects(:execute).with("which #{binary}", anything)
@ssh.expects(:exec!).with("sudo -i which #{binary}", anything)
@action.verify_binary(binary)
end
end

View File

@ -24,12 +24,14 @@ class PuppetServerProvisionerTest < Test::Unit::TestCase
context "verifying binary" do
setup do
@ssh = mock("ssh")
@shell = mock("shell")
@ssh.stubs(:shell).yields(@shell)
@vm.ssh.stubs(:execute).yields(@ssh)
end
should "verify binary exists" do
binary = "foo"
@ssh.expects(:exec!).with("which #{binary}", anything)
@shell.expects(:execute).with("sudo -i which #{binary}", anything)
@action.verify_binary(binary)
end
end
@ -42,19 +44,19 @@ class PuppetServerProvisionerTest < Test::Unit::TestCase
end
should "run the puppetd client" do
@ssh.expects(:exec!).with("sudo -E puppetd --server #{@config.puppet_server} --certname #{@cn}").once
@ssh.expects(:exec!).with("sudo -i puppetd --server #{@config.puppet_server} --certname #{@cn}").once
@action.run_puppetd_client
end
should "run puppetd with given options when given as an array" do
@config.options = ["--modulepath", "modules", "--verbose"]
@ssh.expects(:exec!).with("sudo -E puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
@ssh.expects(:exec!).with("sudo -i puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
@action.run_puppetd_client
end
should "run puppetd with the options when given as a string" do
@config.options = "--modulepath modules --verbose"
@ssh.expects(:exec!).with("sudo -E puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
@ssh.expects(:exec!).with("sudo -i puppetd --modulepath modules --verbose --server #{@config.puppet_server} --certname #{@cn}").once
@action.run_puppetd_client
end

View File

@ -64,15 +64,13 @@ class PuppetProvisionerTest < Test::Unit::TestCase
context "verifying binary" do
setup do
@shell = mock("shell")
@ssh = mock("ssh")
@ssh.stubs(:shell).yields(@shell)
@vm.ssh.stubs(:execute).yields(@ssh)
end
should "verify binary exists" do
binary = "foo"
@shell.expects(:execute).with("which #{binary}", anything)
@ssh.expects(:exec!).with("sudo -i which #{binary}", anything)
@action.verify_binary(binary)
end
end
@ -111,13 +109,11 @@ class PuppetProvisionerTest < Test::Unit::TestCase
context "running puppet client" do
setup do
@ssh = mock("ssh")
@shell = mock("shell")
@ssh.stubs(:shell).yields(@shell)
@vm.ssh.stubs(:execute).yields(@ssh)
end
def expect_puppet_command(command)
@shell.expects(:execute).with("sudo -i 'cd #{@config.pp_path}; #{command}'")
@ssh.expects(:exec!).with("sudo -i 'cd #{@config.pp_path}; #{command}'")
end
should "cd into the pp_path directory and run puppet" do