lib/bolt/shell/bash.rb in bolt-3.3.0 vs lib/bolt/shell/bash.rb in bolt-3.4.0

- old
+ new

@@ -22,13 +22,11 @@ def run_command(command, options = {}, position = []) running_as(options[:run_as]) do output = execute(command, environment: options[:env_vars], sudoable: true) Bolt::Result.for_command(target, - output.stdout.string, - output.stderr.string, - output.exit_code, + output.to_h, 'command', command, position) end end @@ -96,13 +94,11 @@ with_tmpdir do |dir| path = write_executable(dir.to_s, script) dir.chown(run_as) output = execute([path, *arguments], environment: options[:env_vars], sudoable: true) Bolt::Result.for_command(target, - output.stdout.string, - output.stderr.string, - output.exit_code, + output.to_h, 'script', script, position) end end @@ -147,25 +143,25 @@ execute_options[:environment] = envify_params(arguments) end remote_task_path = write_executable(task_dir, executable) + execute_options[:stdin] = stdin + # Avoid the horrors of passing data on stdin via a tty on multiple platforms # by writing a wrapper script that directs stdin to the task. if stdin && target.options['tty'] wrapper = make_wrapper_stringio(remote_task_path, stdin, execute_options[:interpreter]) + # Wrapper script handles interpreter and stdin. Delete these execute options execute_options.delete(:interpreter) + execute_options.delete(:stdin) execute_options[:wrapper] = true remote_task_path = write_executable(dir, wrapper, 'wrapper.sh') end dir.chown(run_as) - # Don't pass parameters on stdin if using a tty, as the parameters are - # already part of the wrapper script. - execute_options[:stdin] = stdin unless stdin && target.options['tty'] - execute_options[:sudoable] = true if run_as output = execute(remote_task_path, **execute_options) end Bolt::Result.for_task(target, output.stdout.string, output.stderr.string, @@ -422,11 +418,12 @@ "[#{@target.safe_name}] #{stream_name}: #{msg.chomp}" end.join("\n") @stream_logger.warn(formatted) end - read_streams[stream] << to_print + read_streams[stream] << to_print + result_output.merged_output << to_print rescue EOFError end # select will either return an empty array if there are no # writable streams or nil if no IO object is available before the @@ -472,10 +469,11 @@ when 0 @logger.trace { "Command `#{command_str}` returned successfully" } when 126 msg = "\n\nThis might be caused by the default tmpdir being mounted "\ "using 'noexec'. See http://pup.pt/task-failure for details and workarounds." - result_output.stderr << msg + result_output.stderr << msg + result_output.merged_output << msg @logger.trace { "Command #{command_str} failed with exit code #{result_output.exit_code}" } else @logger.trace { "Command #{command_str} failed with exit code #{result_output.exit_code}" } end result_output