Also send stdout back in the Result object

It's a legitimate usecase in ansible to register the results of a shell
command and then test its value and make decisions. Not sending stdout
back in the result object would make playbooks that do that break.

There is a risk that we die under the load of really long log files
though - so let's keep track of that.

Change-Id: I2c2fe558d6ec93cef7bb4b1c5abd983488edd745
This commit is contained in:
Monty Taylor 2017-04-27 15:35:28 -05:00
parent 2d079ab813
commit 9b2007a220
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
1 changed files with 5 additions and 1 deletions

View File

@ -123,6 +123,8 @@ from ast import literal_eval
LOG_STREAM_FILE = '/tmp/console.log'
PASSWD_ARG_RE = re.compile(r'^[-]{0,2}pass[-]?(word|wd)?')
# List to save stdout log lines in as we collect them
_log_lines = []
class Console(object):
@ -150,6 +152,7 @@ def follow(fd):
line = fd.readline()
if not line:
break
_log_lines.append(line)
if not line.endswith('\n'):
line += '\n'
newline_warning = True
@ -330,7 +333,8 @@ def zuul_run_command(self, args, check_rc=False, close_fds=True, executable=None
# cmd.stdout.close()
# ZUUL: stdout and stderr are in the console log file
stdout = ''
# ZUUL: return the saved log lines so we can ship them back
stdout = ''.join(_log_lines)
stderr = ''
rc = cmd.returncode