Error and exit if SSH command returns non-zero exit status [closes GH-80]

This commit is contained in:
Mitchell Hashimoto 2010-05-28 23:01:25 -07:00
parent f30cdf3eea
commit 8ea9816552
2 changed files with 9 additions and 0 deletions

View File

@ -150,6 +150,10 @@ module Vagrant
# implementation also reports `:exit_status` to the block if given.
def exec!(command, &block)
block ||= Proc.new do |ch, type, data|
if type == :exit_status && data != 0
raise ActionException.new(:ssh_bad_exit_status, :command => command)
end
ch[:result] ||= ""
ch[:result] << data if [:stdout, :stderr].include?(type)
end

View File

@ -134,6 +134,11 @@
permissions on the following file to 0600 and then try running this command again:
<%= key_path %>
:ssh_bad_exit_status: |-
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
<%= command %>
:ssh_unavailable_windows: |-
`vagrant ssh` isn't available on the Windows platform. The
vagrant.ppk file is available at