From b415279de209771f3329c935c74eceeea9222cb1 Mon Sep 17 00:00:00 2001 From: xz-dev Date: Thu, 14 Sep 2023 14:27:49 +0800 Subject: [PATCH] Disable --tty for subprocess when parent process is non-tty First, stdin not need --tty option, it only dependent --interactive option. Secendly, when running in subprocess mode, disable --tty option if parent process does not have a tty. This prevents the subprocess incorrectly detecting tty and enabling interactive features like `ansible-config init`. For example, if you use `ansible-navigator config init -m stdout > config`, the subprocess will incorrectly detect tty and waiting 'q' to exit less and cause errors of config. This change avoids that. --- src/ansible_runner/config/_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ansible_runner/config/_base.py b/src/ansible_runner/config/_base.py index 819640df..cd39fd88 100644 --- a/src/ansible_runner/config/_base.py +++ b/src/ansible_runner/config/_base.py @@ -25,6 +25,7 @@ import logging import os import re +import sys import stat import tempfile import shutil @@ -495,7 +496,7 @@ def wrap_args_for_containerization(self, new_args = [self.process_isolation_executable] new_args.extend(['run', '--rm']) - if self.runner_mode == 'pexpect' or getattr(self, 'input_fd', False): + if self.runner_mode == 'pexpect' or self.runner_mode == "subprocess" and sys.stdout.isatty(): new_args.extend(['--tty']) new_args.append('--interactive')