Why am I Getting "Error opening terminal: unknown" when I Utilize the Shell Module in an Ansible Tower Job?
Environment
- Ansible Tower >= 3.3
Issue
Attempting to launch a playbook that uses the shell module in an Ansible Tower job fails with the following error:
TASK [command] ***************************************************************** 16:35:09
fatal: [host1]: FAILED! => { "changed": true, "cmd": "/home/ops/test.sh", "delta": "0:00:00.005108", "end": "2017-09-22 16:35:10.318187", "failed": true, "rc": 1, "start": "2017-09-22 16:35:10.313079", "stderr": "Error opening terminal: unknown.", "stderr_lines": ["Error opening terminal: unknown."], "stdout": "", "stdout_lines": []}
Example task:
---
- hosts: all
tasks:
- shell: /tmp/mycommand
Resolution
This problem can be avoided by explicitly setting a value for the TERM environment variable in the task of shell module:
- shell: /tmp/mycommand
environment:
TERM: vt100
Root Cause
When Tower executes the shell module on the target host, the value of the TERM environment variable is set to dumb
. But, some commands require that certain values be set to the TERM(For example: vt100).
In such a case, it is necessary to explicitly set the TERM environment variable.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.
Comments