diff --git a/CHANGELOG.md b/CHANGELOG.md index f4eb23a9b..be40e7c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## 1.2.5 (unreleased) +IMPROVEMENTS: + + - Remote commands that fail will now show the stdout/stderr of the + command that failed. [GH-1203] + BUG FIXES: - Fix uninitialized constant error when configuring Arch Linux network. [GH-1734] diff --git a/plugins/communicators/ssh/communicator.rb b/plugins/communicators/ssh/communicator.rb index db7111137..d3af66499 100644 --- a/plugins/communicators/ssh/communicator.rb +++ b/plugins/communicators/ssh/communicator.rb @@ -57,8 +57,18 @@ module VagrantPlugins }.merge(opts || {}) # Connect via SSH and execute the command in the shell. + stdout = "" + stderr = "" exit_status = connect do |connection| - shell_execute(connection, command, opts[:sudo], &block) + shell_execute(connection, command, opts[:sudo]) do |type, data| + if type == :stdout + stdout += data + elsif type == :stderr + stderr += data + end + + block.call(type, data) if block + end end # Check for any errors @@ -66,7 +76,11 @@ module VagrantPlugins # The error classes expect the translation key to be _key, # but that makes for an ugly configuration parameter, so we # set it here from `error_key` - error_opts = opts.merge(:_key => opts[:error_key]) + error_opts = opts.merge( + :_key => opts[:error_key], + :stdout => stdout, + :stderr => stderr + ) raise opts[:error_class], error_opts end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 6d01a80fc..22302284f 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -397,6 +397,14 @@ en: Vagrant assumes that this means the command failed! %{command} + + Stdout from the command: + + %{stdout} + + Stderr from the command: + + %{stderr} ssh_connect_eacces: |- SSH is getting permission denied errors when attempting to connect to the IP for SSH. This is usually caused by network rules and not being