Allow SSH commands to ignore exit status
This commit is contained in:
parent
eb30074eea
commit
d7af9882f4
|
@ -149,8 +149,12 @@ module Vagrant
|
||||||
# the actual `exec!` implementation, except that this
|
# the actual `exec!` implementation, except that this
|
||||||
# implementation also reports `:exit_status` to the block if given.
|
# implementation also reports `:exit_status` to the block if given.
|
||||||
def exec!(command, options=nil, &block)
|
def exec!(command, options=nil, &block)
|
||||||
|
options = {
|
||||||
|
:error_check => true
|
||||||
|
}.merge(options || {})
|
||||||
|
|
||||||
block ||= Proc.new do |ch, type, data|
|
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] ||= ""
|
||||||
ch[:result] << data if [:stdout, :stderr].include?(type)
|
ch[:result] << data if [:stdout, :stderr].include?(type)
|
||||||
|
|
|
@ -66,7 +66,7 @@ module Vagrant
|
||||||
logger.info "Preparing system for rsync..."
|
logger.info "Preparing system for rsync..."
|
||||||
vm.ssh.upload!(StringIO.new(render_rsync), config.vm.rsync_script)
|
vm.ssh.upload!(StringIO.new(render_rsync), config.vm.rsync_script)
|
||||||
ssh.exec!("sudo chmod +x #{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
|
end
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
@ -59,7 +59,7 @@ class LinuxSystemTest < Test::Unit::TestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
should "remove old crontab entries file" do
|
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)
|
@instance.prepare_rsync(@ssh)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue