Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nmcli.py throws error on CentOS 8-stream #697

Closed
Akasurde opened this issue Jul 27, 2020 · 8 comments
Closed

nmcli.py throws error on CentOS 8-stream #697

Akasurde opened this issue Jul 27, 2020 · 8 comments
Labels
bug This issue/PR relates to a bug module module needs_triage net_tools plugins plugin (any type) python3 traceback

Comments

@Akasurde
Copy link
Member

From @inflatador on Jul 26, 2020 16:56

SUMMARY

Can't create bridge interface with nmcli

ISSUE TYPE
  • Bug Report
COMPONENT NAME

nmcli

ANSIBLE VERSION
ansible 2.9.11
  config file = None
  configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = ~/venvs/P3/lib/python3.6/site-packages/ansible
  executable location = ~/venvs/P3/bin/ansible
  python version = 3.6.10 (default, Dec 21 2019, 11:40:03) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
CONFIGURATION
(returns nothing)
OS / ENVIRONMENT

Running from: Mac OS X virtualenv, pip 20.1.1 installed ansible 2.9.11
Connecting to: CentOS 8-stream
cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
python3 --version
Python 3.6.8

STEPS TO REPRODUCE

run a playbook using nmcli module

---

- name: verify bridge is present
  nmcli:
    type: bridge
    conn_name: labbr0
    state: present

EXPECTED RESULTS

Bridge created

ACTUAL RESULTS
Traceback (most recent call last):
  File "/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py", line 102, in <module>
    _ansiballz_main()
  File "/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.net_tools.nmcli', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib64/python3.6/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib64/python3.6/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1557, in <module>
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1540, in main
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1396, in create_connection
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 690, in execute_command
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in run_command
  File "/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in <listcomp>
  File "/usr/lib64/python3.6/posixpath.py", line 288, in expandvars
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not int
fatal: [linuxhost]: FAILED! => {
    "changed": false,
    "module_stderr": "OpenSSH_7.8p1, LibreSSL 2.6.2\r\ndebug1: Reading configuration data /Users/user/.ssh/config\r\ndebug1: /Users/user/.ssh/config line 3: Applying options for *\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 48: Applying options for *\r\ndebug2: resolve_canonicalize: hostname 192.168.55.209 is address\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: m                module.exit_json(changed=True)
ux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 36721\r\ndebug3: mux_client_request_session: session request sent\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 1\r\nShared connection to 192.168.55.209 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/user/.ansible/tmp/ansible-tmp-1595782089.741004-36751-28759087993374/AnsiballZ_nmcli.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.net_tools.nmcli', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 205, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 96, in _run_module_code\r\n    mod_name, mod_spec, pkg_name, script_name)\r\n  File \"/usr/lib64/python3.6/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1557, in <module>\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1540, in main\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1396, in create_connection\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 690, in execute_command\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2502, in run_command\r\n  File \"/tmp/ansible_nmcli_payload_8z_asoku/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2502, in <listcomp>\r\n  File \"/usr/lib64/python3.6/posixpath.py\", line 288, in expandvars\r\n    path = os.fspath(path)\r\nTypeError: expected str, bytes or os.PathLike object, not int\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

Copied from original issue: ansible/ansible#70906

@ansibullbot
Copy link
Collaborator

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link
Collaborator

@shokinn
Copy link

shokinn commented Jul 28, 2020

Same issue as above on Ubuntu 20.04 with python 3.8.2.

ANSIBLE VERSION
ansible 2.9.11
  config file = None
  configured module search path = ['/Users/phg/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/phg/.local/pipx/venvs/ansible/lib/python3.8/site-packages/ansible
  executable location = /Users/phg/.local/bin/ansible
  python version = 3.8.4 (default, Jul 14 2020, 02:58:48) [Clang 11.0.3 (clang-1103.0.32.62)]
CONFIGURATION
(returns nothing)
OS / ENVIRONMENT

Running from: Mac OS X virtualenv, pip 20.1.1 installed ansible 2.9.11
Connecting to: Ubuntu 20.04

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal
# python3 --version
Python 3.8.2
STEPS TO REPRODUCE

run a playbook using nmcli module

---

- name: "Setup bridge ({{ libvirt.network.bridges.br0.name }}) for client access"
  become: yes
  nmcli:
    state: present
    type: bridge
    autoconnect: yes
    conn_name: "{{ libvirt.network.bridges.br0.name }}"
EXPECTED RESULTS

Bridge created

ACTUAL RESULTS
TASK [Setup bridge (br0) for client access] ********************************************************************************************************************************************************************************************************************************************************************************
task path: /Users/phg/Workspace/Privat/playbooks/playbooks/APU2C4_home_router/tasks/setup_virtualization_environment.yml:37
<10.11.42.201> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.42.201> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 10.11.42.201 '/bin/sh -c '"'"'echo ~ansible && sleep 0'"'"''
<10.11.42.201> (0, b'/home/ansible\n', b'')
<10.11.42.201> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.42.201> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 10.11.42.201 '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/ansible/.ansible/tmp `"&& mkdir /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522 && echo ansible-tmp-1595929983.072425-7387-182491496002522="` echo /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522 `" ) && sleep 0'"'"''
<10.11.42.201> (0, b'ansible-tmp-1595929983.072425-7387-182491496002522=/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522\n', b'')
Using module file /Users/phg/.local/pipx/venvs/ansible/lib/python3.8/site-packages/ansible/modules/net_tools/nmcli.py
<10.11.42.201> PUT /Users/phg/.ansible/tmp/ansible-local-7332y51bet_a/tmpp10sm01r TO /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py
<10.11.42.201> SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 '[10.11.42.201]'
<10.11.42.201> (0, b'sftp> put /Users/phg/.ansible/tmp/ansible-local-7332y51bet_a/tmpp10sm01r /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py\n', b'')
<10.11.42.201> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.42.201> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 10.11.42.201 '/bin/sh -c '"'"'chmod u+x /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/ /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py && sleep 0'"'"''
<10.11.42.201> (0, b'', b'')
<10.11.42.201> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.42.201> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 -tt 10.11.42.201 '/bin/sh -c '"'"'sudo -H -S -n  -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-ktqktlbrvispwnnqeethiojekjpqacbb ; /usr/bin/env python3 /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''
Escalation succeeded
<10.11.42.201> (1, b'Traceback (most recent call last):\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 102, in <module>\r\n    _ansiballz_main()\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 40, in invoke_module\r\n    runpy.run_module(mod_name=\'ansible.modules.net_tools.nmcli\', init_globals=None, run_name=\'__main__\', alter_sys=True)\r\n  File "/usr/lib/python3.8/runpy.py", line 206, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File "/usr/lib/python3.8/runpy.py", line 96, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code\r\n    exec(code, run_globals)\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1557, in <module>\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1540, in main\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1396, in create_connection\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 690, in execute_command\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in run_command\r\n  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in <listcomp>\r\n  File "/usr/lib/python3.8/posixpath.py", line 284, in expandvars\r\n    path = os.fspath(path)\r\nTypeError: expected str, bytes or os.PathLike object, not int\r\n', b'Shared connection to 10.11.42.201 closed.\r\n')
<10.11.42.201> Failed to connect to the host via ssh: Shared connection to 10.11.42.201 closed.
<10.11.42.201> ESTABLISH SSH CONNECTION FOR USER: ansible
<10.11.42.201> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o 'User="ansible"' -o ConnectTimeout=10 -o ControlPath=/Users/phg/.ansible/cp/c54fae2d43 10.11.42.201 '/bin/sh -c '"'"'rm -f -r /home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/ > /dev/null 2>&1 && sleep 0'"'"''
<10.11.42.201> (0, b'', b'')
The full traceback is:
Traceback (most recent call last):
  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 102, in <module>
    _ansiballz_main()
  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible.modules.net_tools.nmcli', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.8/runpy.py", line 206, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1557, in <module>
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1540, in main
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 1396, in create_connection
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py", line 690, in execute_command
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in run_command
  File "/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py", line 2502, in <listcomp>
  File "/usr/lib/python3.8/posixpath.py", line 284, in expandvars
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not int
fatal: [dev]: FAILED! => {
    "changed": false,
    "module_stderr": "Shared connection to 10.11.42.201 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py\", line 102, in <module>\r\n    _ansiballz_main()\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py\", line 94, in _ansiballz_main\r\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n  File \"/home/ansible/.ansible/tmp/ansible-tmp-1595929983.072425-7387-182491496002522/AnsiballZ_nmcli.py\", line 40, in invoke_module\r\n    runpy.run_module(mod_name='ansible.modules.net_tools.nmcli', init_globals=None, run_name='__main__', alter_sys=True)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 206, in run_module\r\n    return _run_module_code(code, init_globals, run_name, mod_spec)\r\n  File \"/usr/lib/python3.8/runpy.py\", line 96, in _run_module_code\r\n    _run_code(code, mod_globals, init_globals,\r\n  File \"/usr/lib/python3.8/runpy.py\", line 86, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1557, in <module>\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1540, in main\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 1396, in create_connection\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/modules/net_tools/nmcli.py\", line 690, in execute_command\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2502, in run_command\r\n  File \"/tmp/ansible_nmcli_payload_5mtmqiym/ansible_nmcli_payload.zip/ansible/module_utils/basic.py\", line 2502, in <listcomp>\r\n  File \"/usr/lib/python3.8/posixpath.py\", line 284, in expandvars\r\n    path = os.fspath(path)\r\nTypeError: expected str, bytes or os.PathLike object, not int\r\n",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}

@kriansa
Copy link

kriansa commented Aug 9, 2020

Same thing is happening on Arch.

@itcultus
Copy link

itcultus commented Sep 12, 2020

Same thing with:
Control node: Fedora 31 or openSUSE Leap 15.2
Target node: openSUSE Leap 15.2, or RHEL 8.1

Python on control node:
openSUSE Leap 15.2: Python 3.6.10
Fedora 31: Python 3.7.9
Ansible versions:
Leap: 2.9.13
Fedora 31: 2.9.12

Python on target node:
openSUSE Leap 15.2: Python 3.6.10
RHEL 8.1: Python 3.6.8

@felixfontein
Copy link
Collaborator

This has been:

resolved_by_pr #477

(Unfortunately that PR has not yet been backported to ansible/ansible's stable-2.9 branch.)

@udis
Copy link

udis commented Oct 13, 2020

@felixfontein Hi, any plans to backport this one to ansible 2.9 ?

@felixfontein
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug module module needs_triage net_tools plugins plugin (any type) python3 traceback
Projects
None yet
Development

No branches or pull requests

7 participants