Ansible command module: allow to use stdin param

Otherwise executed programs waiting for stdin get stuck until the
build times out.

Change-Id: I98d1b1b30119ad3cadaf60bbdd3cfbd26dc213ff
This commit is contained in:
Pierre-Louis Bonicoli
2020-08-05 02:19:07 +02:00
parent e64fd8fff8
commit 844a7c87bb
2 changed files with 22 additions and 9 deletions

View File

@@ -2,3 +2,16 @@
tasks:
- name: Some command
command: echo 123
- name: Check that 'stdin' parameter is handled by 'zuul_run_command' (which
is a fork of ansible.module_utils.basic.run_command)
command:
cmd: cat -
stdin: test_stdin_param
register: _run_command_result
- assert:
that:
- _run_command_result is success
- _run_command_result.rc == 0
- "_run_command_result.stdout == 'test_stdin_param'"

View File

@@ -421,15 +421,15 @@ def zuul_run_command(self, args, zuul_log_id, check_rc=False, close_fds=True, ex
#
# # ZUUL: stderr follows stdout
# rpipes = [cmd.stdout]
#
# if data:
# if not binary_data:
# data += '\n'
# if isinstance(data, text_type):
# data = to_bytes(data)
# cmd.stdin.write(data)
# cmd.stdin.close()
#
if data:
if not binary_data:
data += '\n'
if isinstance(data, text_type):
data = to_bytes(data)
cmd.stdin.write(data)
cmd.stdin.close()
# while True:
# rfds, wfds, efds = select.select(rpipes, [], rpipes, 1)
# stdout += self._read_from_pipes(rpipes, rfds, cmd.stdout)