ansible-collections / ansible.netcommon

Ansible Network Collection for Common Code
GNU General Public License v3.0
144 stars 103 forks source link

Using network_cli connection method on a illumos control node fails with termios.error: (22, 'Invalid argument') #369

Closed olbohlen closed 2 years ago

olbohlen commented 2 years ago
SUMMARY

network_cli fails on illumos/SunOS/Solaris control nodes because termios tries to operate on the parent pty. When I try to run any ansible module from my illumos (SunOS) control node using the network_cli connection method, I get the following error:

The full traceback is: Traceback (most recent call last): File "/export/home/olbohlen/.local/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 1155, in start_connection termios.tcsetattr(master, termios.TCSANOW, new) termios.error: (22, 'Invalid argument')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/export/home/olbohlen/.local/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 158, in run res = self._execute() File "/export/home/olbohlen/.local/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 532, in _execute self._connection = self._get_connection(cvars, templar) File "/export/home/olbohlen/.local/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 965, in _get_connection socket_path = start_connection(self._play_context, options, self._task._uuid) File "/export/home/olbohlen/.local/lib/python3.9/site-packages/ansible/executor/task_executor.py", line 1161, in start_connection termios.tcsetattr(master, termios.TCSANOW, old) termios.error: (22, 'Invalid argument') bifroest.mgmt.home.eenfach.de | FAILED! => { "msg": "Unexpected failure during module execution.", "stdout": "" }

(1481) x230:/export/home/olbohlen/git/ansible-playbooks/sin$ ansible --version ansible [core 2.12.2] config file = /export/home/olbohlen/git/ansible-playbooks/sin/ansible.cfg configured module search path = ['/export/home/olbohlen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /export/home/olbohlen/.local/lib/python3.9/site-packages/ansible ansible collection location = /export/home/olbohlen/.ansible/collections:/usr/share/ansible/collections executable location = /export/home/olbohlen/.local/bin/ansible python version = 3.9.10 (main, Jan 17 2022, 16:23:45) [GCC 7.5.0] jinja version = 3.0.3 libyaml = True

The reason is described also in https://github.com/amoffat/sh/issues/143, you cannot call termios.tcsetattr() on the master side of the pty pair on Unix98 systems like illumos, Solaris, HP-UX, etc...

Unfortunately my python knowledge is way too bad to fix the issue by myself.

ISSUE TYPE
COMPONENT NAME

network_cli

ANSIBLE VERSION
$ ansible --version
ansible [core 2.12.2]
  config file = /export/home/olbohlen/git/ansible-playbooks/sin/ansible.cfg
  configured module search path = ['/export/home/olbohlen/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /export/home/olbohlen/.local/lib/python3.9/site-packages/ansible
  ansible collection location = /export/home/olbohlen/.ansible/collections:/usr/share/ansible/collections
  executable location = /export/home/olbohlen/.local/bin/ansible
  python version = 3.9.10 (main, Jan 17 2022, 16:23:45) [GCC 7.5.0]
  jinja version = 3.0.3
  libyaml = True
COLLECTION VERSION
(546) x230:/export/home/olbohlen$ ansible-galaxy collection list ansible.netcommon                                

# /export/home/olbohlen/.local/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 2.5.0  
CONFIGURATION
(548) x230:/export/home/olbohlen$ ansible-config dump --only-changed | cat
DEFAULT_HOST_LIST(/export/home/olbohlen/.ansible.cfg) = ['/export/home/olbohlen/inventory']
DEFAULT_TIMEOUT(/export/home/olbohlen/.ansible.cfg) = 30
DEFAULT_TRANSPORT(/export/home/olbohlen/.ansible.cfg) = ssh
OS / ENVIRONMENT

OpenIndiana Hipster 2021.10, SunOS x230 5.11 illumos-3e8b6b84e5 i86pc i386 i86pc

STEPS TO REPRODUCE

It is enough to try to run the ping module, even this will fail.

ansible -m ping bifroest.mgmt.home.eenfach.de 
EXPECTED RESULTS

I expected to get the typical "ping": "pong" reply back

ACTUAL RESULTS
(1488) x230:/export/home/olbohlen/git/ansible-playbooks/sin$ ansible -m ping bifroest.mgmt.home.eenfach.de                                   
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: termios.error: (22, 'Invalid argument')
bifroest.mgmt.home.eenfach.de | FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
Qalthos commented 2 years ago

You got redirected here by ansibot, but this really is an issue with ansible, and task_executor in particular. https://github.com/ansible/ansible/issues/76972 has been reopened, so I'm closing this issue because there really isn't anything netcommon can do.