Puppet is now RVM friendly
This commit is contained in:
parent
55b7321f2b
commit
93d241f4ce
|
@ -43,7 +43,9 @@ module Vagrant
|
|||
|
||||
def verify_binary(binary)
|
||||
vm.ssh.execute do |ssh|
|
||||
ssh.exec!("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
|
||||
ssh.shell do |sh|
|
||||
sh.execute("which #{binary}", :error_class => PuppetError, :_key => :puppet_not_detected, :binary => binary)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -66,16 +68,19 @@ module Vagrant
|
|||
end
|
||||
|
||||
def run_puppet_client
|
||||
options = config.options
|
||||
options = options.join(" ") if options.is_a?(Array)
|
||||
command = "cd #{config.pp_path} && sudo -E puppet #{options} #{@manifest}"
|
||||
options = [config.options].flatten
|
||||
options << @manifest
|
||||
options = options.join(" ")
|
||||
|
||||
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
|
||||
|
||||
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
|
||||
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
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -64,13 +64,15 @@ 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"
|
||||
@ssh.expects(:exec!).with("which #{binary}", anything)
|
||||
@shell.expects(:execute).with("which #{binary}", anything)
|
||||
@action.verify_binary(binary)
|
||||
end
|
||||
end
|
||||
|
@ -109,29 +111,29 @@ 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}'")
|
||||
end
|
||||
|
||||
should "cd into the pp_path directory and run puppet" do
|
||||
@ssh.expects(:exec!).with("cd #{@config.pp_path} && sudo -E puppet #{@manifest}").once
|
||||
expect_puppet_command("puppet #{@manifest}")
|
||||
@action.run_puppet_client
|
||||
end
|
||||
|
||||
should "cd into the pp_path directory and run puppet with given options when given as an array" do
|
||||
@config.options = ["--modulepath", "modules", "--verbose"]
|
||||
@ssh.expects(:exec!).with("cd #{@config.pp_path} && sudo -E puppet --modulepath modules --verbose #{@manifest}").once
|
||||
expect_puppet_command("puppet --modulepath modules --verbose #{@manifest}")
|
||||
@action.run_puppet_client
|
||||
end
|
||||
|
||||
should "cd into the pp_path directory and run puppet with the options when given as a string" do
|
||||
@config.options = "--modulepath modules --verbose"
|
||||
@ssh.expects(:exec!).with("cd #{@config.pp_path} && sudo -E puppet --modulepath modules --verbose #{@manifest}").once
|
||||
@action.run_puppet_client
|
||||
end
|
||||
|
||||
should "check the exit status if that is given" do
|
||||
@ssh.stubs(:exec!).yields(nil, :exit_status, :foo)
|
||||
@ssh.expects(:check_exit_status).with(:foo, anything).once
|
||||
expect_puppet_command("puppet --modulepath modules --verbose #{@manifest}")
|
||||
@action.run_puppet_client
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue