diff --git a/lib/vagrant/plugin/remote/communicator.rb b/lib/vagrant/plugin/remote/communicator.rb index 3de0f2f00..fd30396aa 100644 --- a/lib/vagrant/plugin/remote/communicator.rb +++ b/lib/vagrant/plugin/remote/communicator.rb @@ -40,9 +40,12 @@ module Vagrant @client.upload(@machine, from, to) end - def execute(cmd, opts=nil) + def execute(cmd, opts=nil, &block) @logger.debug("remote communicator, executing command") - @client.execute(@machine, cmd, opts) + res = @client.execute(@machine, cmd, opts) + yield :stdout, res.stdout if block_given? + yield :stderr, res.stderr if block_given? + res.exit_code end def sudo(cmd, opts=nil) diff --git a/plugins/commands/serve/client/communicator.rb b/plugins/commands/serve/client/communicator.rb index 23f7f3c1f..0da66bb22 100644 --- a/plugins/commands/serve/client/communicator.rb +++ b/plugins/commands/serve/client/communicator.rb @@ -131,7 +131,7 @@ module VagrantPlugins @logger.debug("excuting") res = client.execute(req) @logger.debug("excution result: #{res}") - res.exit_code + res end # @param [Vagrant::Machine] diff --git a/plugins/commands/serve/service/communicator_service.rb b/plugins/commands/serve/service/communicator_service.rb index 22d798cfd..3bafd1938 100644 --- a/plugins/commands/serve/service/communicator_service.rb +++ b/plugins/commands/serve/service/communicator_service.rb @@ -208,11 +208,17 @@ module VagrantPlugins plugin = Vagrant.plugin("2").manager.communicators[plugin_name.to_s.to_sym] communicator = plugin.new(machine) opts.transform_keys!(&:to_sym) - exit_code = communicator.execute(cmd.command, opts) + output = {stdout: '', stderr: ''} + exit_code = communicator.execute(cmd.command, opts) { + |type, data| output[type] << data if output[type] + } logger.debug("command exit code: #{exit_code}") + logger.debug("command output: #{output}") SDK::Communicator::ExecuteResp.new( - exit_code: exit_code + exit_code: exit_code, + stdout: output[:stdout], + stderr: output[:stderr] ) end end