Skip to content

Commit

Permalink
openbsd_pkg: set TERM to 'dumb' in execute_command (#6149)
Browse files Browse the repository at this point in the history
* 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 <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
(cherry picked from commit b97bee3)
  • Loading branch information
eest authored and patchback[bot] committed Mar 14, 2023
1 parent 94efeca commit e25afee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions changelogs/fragments/6149-openbsd_pkg-term.yml
Original file line number Diff line number Diff line change
@@ -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).
6 changes: 5 additions & 1 deletion plugins/modules/openbsd_pkg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e25afee

Please sign in to comment.