Allow SSH commands to ignore exit status

This commit is contained in:
Mitchell Hashimoto 2010-05-29 23:33:37 -07:00
parent eb30074eea
commit d7af9882f4
3 changed files with 7 additions and 3 deletions

View File

@ -149,8 +149,12 @@ module Vagrant
# the actual `exec!` implementation, except that this
# implementation also reports `:exit_status` to the block if given.
def exec!(command, options=nil, &block)
options = {
:error_check => true
}.merge(options || {})
block ||= Proc.new do |ch, type, data|
check_exit_status(data, command, options) if type == :exit_status
check_exit_status(data, command, options) if type == :exit_status && options[:error_check]
ch[:result] ||= ""
ch[:result] << data if [:stdout, :stderr].include?(type)

View File

@ -66,7 +66,7 @@ module Vagrant
logger.info "Preparing system for rsync..."
vm.ssh.upload!(StringIO.new(render_rsync), config.vm.rsync_script)
ssh.exec!("sudo chmod +x #{config.vm.rsync_script}")
ssh.exec!("sudo rm #{config.vm.rsync_crontab_entry_file}")
ssh.exec!("sudo rm #{config.vm.rsync_crontab_entry_file}", :error_check => false)
end
#-------------------------------------------------------------------

View File

@ -59,7 +59,7 @@ class LinuxSystemTest < Test::Unit::TestCase
end
should "remove old crontab entries file" do
@ssh.expects(:exec!).with("sudo rm #{@mock_env.config.vm.rsync_crontab_entry_file}")
@ssh.expects(:exec!).with("sudo rm #{@mock_env.config.vm.rsync_crontab_entry_file}", :error_check => false)
@instance.prepare_rsync(@ssh)
end