1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Do not require TTY for 'apt-key' operations (#48580)

The 'gpg' command supports the '--no-tty' option, which disables any use
of a TTY during its execution. This parameter is sometimes required for
non-interactive operation to avoid any questions for the user.

The 'apt-key adv' command can pass additional parameters to the
underlying 'gpg' command. This patch adds the '--no-tty' option to avoid
issues with APT key imports when Ansible pipelining active, which
disables the use of a dedicated TTY.
This commit is contained in:
Maciej Delmanowski 2018-11-19 13:40:06 +01:00 committed by John R Barker
parent 475d69da69
commit c7e2226035

View file

@ -216,9 +216,9 @@ def download_key(module, url):
def import_key(module, keyring, keyserver, key_id): def import_key(module, keyring, keyserver, key_id):
if keyring: 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: 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): for retry in range(5):
lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C') lang_env = dict(LANG='C', LC_ALL='C', LC_MESSAGES='C')
(rc, out, err) = module.run_command(cmd, environ_update=lang_env) (rc, out, err) = module.run_command(cmd, environ_update=lang_env)