From b97bee3fd6f2a579501f75863285cc689ca63343 Mon Sep 17 00:00:00 2001 From: Patrik Lundin Date: Tue, 14 Mar 2023 23:01:06 +0100 Subject: [PATCH] openbsd_pkg: set TERM to 'dumb' in execute_command (#6149) * openbsd_pkg: set TERM to 'dumb' in execute_command Keeps pkg_add happy when someone running ansible is using a TERM that the managed OpenBSD host does not know about. Fixes #5738. Selection of specific TERM from discussion at https://marc.info/?l=openbsd-tech&m=167290482630534&w=2 * Add changelog fragment for openbsd_pkg TERM fix * Update changelogs/fragments/6149-openbsd_pkg-term.yml Co-authored-by: Felix Fontein --------- Co-authored-by: Felix Fontein --- changelogs/fragments/6149-openbsd_pkg-term.yml | 2 ++ plugins/modules/openbsd_pkg.py | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/6149-openbsd_pkg-term.yml diff --git a/changelogs/fragments/6149-openbsd_pkg-term.yml b/changelogs/fragments/6149-openbsd_pkg-term.yml new file mode 100644 index 0000000000..5fe1e5a6db --- /dev/null +++ b/changelogs/fragments/6149-openbsd_pkg-term.yml @@ -0,0 +1,2 @@ +minor_changes: + - openbsd_pkg - set ``TERM`` to ``'dumb'`` in ``execute_command()`` to make module less dependant on the ``TERM`` environment variable set on the Ansible controller (https://github.com/ansible-collections/community.general/pull/6149). diff --git a/plugins/modules/openbsd_pkg.py b/plugins/modules/openbsd_pkg.py index 62a662c3c4..2baea828ab 100644 --- a/plugins/modules/openbsd_pkg.py +++ b/plugins/modules/openbsd_pkg.py @@ -152,7 +152,11 @@ def execute_command(cmd, module): # This makes run_command() use shell=False which we need to not cause shell # expansion of special characters like '*'. cmd_args = shlex.split(cmd) - return module.run_command(cmd_args) + + # We set TERM to 'dumb' to keep pkg_add happy if the machine running + # ansible is using a TERM that the managed machine does not know about, + # e.g.: "No progress meter: failed termcap lookup on xterm-kitty". + return module.run_command(cmd_args, environ_update={'TERM': 'dumb'}) # Function used to find out if a package is currently installed.