diff --git a/changelogs/fragments/48580-apt_key-no-tty.yaml b/changelogs/fragments/48580-apt_key-no-tty.yaml new file mode 100644 index 0000000000..fe3d0f34b1 --- /dev/null +++ b/changelogs/fragments/48580-apt_key-no-tty.yaml @@ -0,0 +1,3 @@ +bugfixes: + - apt_key - Disable TTY requirement in GnuPG for the module to work correctly + when SSH pipelining is enabled (https://github.com/ansible/ansible/pull/48580) diff --git a/lib/ansible/modules/packaging/os/apt_key.py b/lib/ansible/modules/packaging/os/apt_key.py index 7f07b3b3a0..05921a504b 100644 --- a/lib/ansible/modules/packaging/os/apt_key.py +++ b/lib/ansible/modules/packaging/os/apt_key.py @@ -213,9 +213,9 @@ def download_key(module, url): def import_key(module, keyring, keyserver, key_id): if keyring: - cmd = "%s --keyring %s adv --keyserver %s --recv %s" % (apt_key_bin, keyring, keyserver, key_id) + cmd = "%s --keyring %s adv --no-tty --keyserver %s --recv %s" % (apt_key_bin, keyring, keyserver, key_id) else: - cmd = "%s adv --keyserver %s --recv %s" % (apt_key_bin, keyserver, key_id) + cmd = "%s adv --no-tty --keyserver %s --recv %s" % (apt_key_bin, keyserver, key_id) for retry in range(5): lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') (rc, out, err) = module.run_command(cmd, environ_update=lang_env)