Puppet is now RVM friendly
This commit is contained in:
parent
55b7321f2b
commit
93d241f4ce
|
@ -43,7 +43,9 @@ module Vagrant
|
||||||
|
|
||||||
def verify_binary(binary)
|
def verify_binary(binary)
|
||||||
vm.ssh.execute do |ssh|
|
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
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -66,16 +68,19 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_puppet_client
|
def run_puppet_client
|
||||||
options = config.options
|
options = [config.options].flatten
|
||||||
options = options.join(" ") if options.is_a?(Array)
|
options << @manifest
|
||||||
command = "cd #{config.pp_path} && sudo -E puppet #{options} #{@manifest}"
|
options = options.join(" ")
|
||||||
|
|
||||||
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
|
env.ui.info I18n.t("vagrant.provisioners.puppet.running_puppet")
|
||||||
|
|
||||||
vm.ssh.execute do |ssh|
|
vm.ssh.execute do |ssh|
|
||||||
ssh.exec!(command) do |channel, type, data|
|
ssh.shell do |sh|
|
||||||
ssh.check_exit_status(data, command) if type == :exit_status
|
sh.execute "sudo -i 'cd #{config.pp_path}; puppet #{options}'" do |process|
|
||||||
env.ui.info("#{data}: #{type}") if type != :exit_status
|
process.on_output do |p, data|
|
||||||
|
env.ui.info(data)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -64,13 +64,15 @@ class PuppetProvisionerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
context "verifying binary" do
|
context "verifying binary" do
|
||||||
setup do
|
setup do
|
||||||
|
@shell = mock("shell")
|
||||||
@ssh = mock("ssh")
|
@ssh = mock("ssh")
|
||||||
|
@ssh.stubs(:shell).yields(@shell)
|
||||||
@vm.ssh.stubs(:execute).yields(@ssh)
|
@vm.ssh.stubs(:execute).yields(@ssh)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "verify binary exists" do
|
should "verify binary exists" do
|
||||||
binary = "foo"
|
binary = "foo"
|
||||||
@ssh.expects(:exec!).with("which #{binary}", anything)
|
@shell.expects(:execute).with("which #{binary}", anything)
|
||||||
@action.verify_binary(binary)
|
@action.verify_binary(binary)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -109,29 +111,29 @@ class PuppetProvisionerTest < Test::Unit::TestCase
|
||||||
context "running puppet client" do
|
context "running puppet client" do
|
||||||
setup do
|
setup do
|
||||||
@ssh = mock("ssh")
|
@ssh = mock("ssh")
|
||||||
|
@shell = mock("shell")
|
||||||
|
@ssh.stubs(:shell).yields(@shell)
|
||||||
@vm.ssh.stubs(:execute).yields(@ssh)
|
@vm.ssh.stubs(:execute).yields(@ssh)
|
||||||
end
|
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
|
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
|
@action.run_puppet_client
|
||||||
end
|
end
|
||||||
|
|
||||||
should "cd into the pp_path directory and run puppet with given options when given as an array" do
|
should "cd into the pp_path directory and run puppet with given options when given as an array" do
|
||||||
@config.options = ["--modulepath", "modules", "--verbose"]
|
@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
|
@action.run_puppet_client
|
||||||
end
|
end
|
||||||
|
|
||||||
should "cd into the pp_path directory and run puppet with the options when given as a string" do
|
should "cd into the pp_path directory and run puppet with the options when given as a string" do
|
||||||
@config.options = "--modulepath modules --verbose"
|
@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 "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
|
|
||||||
@action.run_puppet_client
|
@action.run_puppet_client
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue