dellemc.enterprise_sonic icon indicating copy to clipboard operation
dellemc.enterprise_sonic copied to clipboard

[BUG]: "a bytes-like object is required, not 'str'" on sonic_interface module

Open jguilford opened this issue 1 year ago • 1 comments

Bug Description

"msg": "a bytes-like object is required, not 'str'", "invocation": { "module_args": { "config": [ { "name": "Eth1/1", "description": "Uplink to UNV-LR1-SP1", "enabled": null, "mtu": null, "speed": null, "auto_negotiate": null, "advertised_speed": null, "fec": null } ], "state": "merged" }

Product Name

Dell Enterprise Sonic

Component or Module Name

sonic_interface

DellEMC Enterprise SONiC Ansible Collection Version

2.4.0

SONiC Software Version

4.0.1

Configuration

Ran through AWX

- name: Interface Manager
  connection: httpapi
  dellemc.enterprise_sonic.sonic_interfaces:
    config:
      - name: "{{ item.name }}"
        description: "{{ item.description }}"

enabled: "{{ item.enabled | bool }}"

    state: merged

Steps to Reproduce

Ran through AWX

Expected Behavior

Update Description, and Enabled State without Error

Actual Behavior

"a bytes-like object is required, not 'str'"

Logs

{ "started": 1, "finished": 1, "stdout": "", "stderr": "", "stdout_lines": [], "stderr_lines": [], "ansible_job_id": "j708448897745.301", "results_file": "/runner/.ansible_async/j708448897745.301", "code": -32603, "msg": "a bytes-like object is required, not 'str'", "invocation": { "module_args": { "config": [ { "name": "PortChannel 3", "description": "UNV-LR1-L1 E1/3 & UNV-LR1-L2 E1/3", "enabled": null, "mtu": null, "speed": null, "auto_negotiate": null, "advertised_speed": null, "fec": null } ], "state": "merged" } }

Screenshots

No response

Additional Information

No response

jguilford avatar Feb 19 '24 12:02 jguilford

The error message shown here indicates a problem in the software configuration on the server. The 2.4.0 version of this collection works with no problems running the specified playbook against a SONiC 4.0.1 image. (See output below.)

A separate question: Why is the reference for the last variable shown as "{{ item.enabled | bool }}"? (What is the intent of the " | bool" in the reference? This doesn't cause a failure, but I'm wondering if it is intentional.)

Posted below is an example of a successful run of an equivalent playbook using a version 2.4.0 installation of the enterprise_sonic collection on a server loaded with Python 3.11.9 and Ansible version 2.17.2 against a SONiC 4.0.1 image. Also posted is a list of the most relevant installed software versions on the Ansible server from which this run was executed. Changed configuration lines for the 'target' interface in the 'before' and 'after' playbook output are marked by "<<<".

NOTE: It looks like there is no "bug" in the enterprise_sonic Ansible resource module collection to address here, so I would like to close this Github "Issue". If this problem is still present in your environment and you feel that further investigation by our software group is warranted, please post the same information for your failing run as the information posted below for ours:

  • SONiC "show version" output
  • server OS information
  • Ansible version information
  • python and python3 version information
  • ansible-pylibssh version information
  • paramiko version information
  • "ansible-galaxy collection list" output through the line showing the installed ansible.netcommon version
  • Any relevant "vars" definition referenced in the playbook
  • The failing playbook
  • A failing run of the "problem" playbook in 'verbose' mode (-vvvv, as shown below).

Software Versions:

 SONiC

sonic# show version

Software Version : '4.0.1-Enterprise_Advanced' Product : Enterprise SONiC Distribution by Dell Technologies Distribution : '10.12' Kernel : '4.19.0-9-2-amd64' Config DB Version : version_4_0_1 Build Commit : 'b81f07c4a' Build Date : Fri May 27 06:47:04 UTC 2022 Built By : sonicbld@sonic-lvn-csg-003 Platform : x86_64-dellemc_z9332f_d1508-r0 HwSKU : DellEMC-Z9332f-O32 ASIC : broadcom Hardware Version : A00 Serial Number : TH04CN21CEH009310001 Uptime : 21:46:16 up 18:59, 1 user, load average: 1.83, 1.93, 1.97 Mfg : Dell EMC

  Ansible server:

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> cat /etc/os-release NAME="openSUSE Leap" VERSION="15.5" ID="opensuse-leap" ID_LIKE="suse opensuse" VERSION_ID="15.5" PRETTY_NAME="openSUSE Leap 15.5" ANSI_COLOR="0;32" CPE_NAME="cpe:/o:opensuse:leap:15.5" BUG_REPORT_URL="https://bugs.opensuse.org" HOME_URL="https://www.opensuse.org/" DOCUMENTATION_URL="https://en.opensuse.org/Portal:Leap" LOGO="distributor-logo-Leap"

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> ansible --version ansible [core 2.17.2] config file = None configured module search path = ['/home/kerry/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible ansible collection location = /home/kerry/.ansible/collections:/usr/share/ansible/collections executable location = /home/kerry/.py11venv/bin/ansible python version = 3.11.9 (main, Apr 18 2024, 16:44:43) [GCC] (/home/kerry/.py11venv/bin/python) jinja version = 3.1.4 libyaml = True

(.py11venv) kerry@opensuse155:/v2.4.0_clone/dellemc.enterprise_sonic python -V Python 3.11.9 (.py11venv) kerry@opensuse155:/v2.4.0_clone/dellemc.enterprise_sonic python3 -V Python 3.11.9

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> pip3 show -V ansible-pylibssh Name: ansible-pylibssh Version: 1.2.2 Summary: Python bindings for libssh client specific to Ansible use case Home-page: https://github.com/ansible/pylibssh Author: Ansible, Inc. Author-email: info+github/ansible/[email protected] License: LGPLv2+ Location: /home/kerry/.py11venv/lib64/python3.11/site-packages Requires: Required-by:

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> pip3 show -V paramiko Name: paramiko Version: 3.4.0 Summary: SSH2 protocol library Home-page: https://paramiko.org Author: Jeff Forcier Author-email: [email protected] License: LGPL Location: /home/kerry/.py11venv/lib64/python3.11/site-packages Requires: bcrypt, cryptography, pynacl Required-by:

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> ansible-galaxy collection list

/home/kerry/.ansible/collections/ansible_collections

Collection Version


dellemc.enterprise_sonic 2.4.0

/home/kerry/.py11venv/lib/python3.11/site-packages/ansible_collections

Collection Version


amazon.aws 8.1.0 ansible.netcommon 6.1.3 ansible.posix 1.5.4 ansible.utils 4.1.0 * * *


Playbook:

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> cat ~/playbooks/intf_cfg_jguilford.yaml

Issue 339 reproduction playbook

  • name: Configure Host interface parameters hosts: datacenter gather_facts: False connection: httpapi collections:

    • dellemc.enterprise_sonic vars: item: name: "Eth1/12" description: "path to some server" enabled: True

    tasks:

    • name: sonic base interface configuration sonic_interfaces: config: - name: "{{item.name}}" description: "{{item.description}}" enabled: "{{item.enabled | bool}}" state: merged

Playbook Execution

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic> ansible-playbook -i tests/regression/hosts ~/playbooks/intf_cfg_jguilford.yaml -vvvv ansible-playbook [core 2.17.2] config file = None configured module search path = ['/home/kerry/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible ansible collection location = /home/kerry/.ansible/collections:/usr/share/ansible/collections executable location = /home/kerry/.py11venv/bin/ansible-playbook python version = 3.11.9 (main, Apr 18 2024, 16:44:43) [GCC] (/home/kerry/.py11venv/bin/python) jinja version = 3.1.4 libyaml = True setting up inventory plugins * * * Parsed /home/kerry/v2.4.0_clone/dellemc.enterprise_sonic/tests/regression/hosts inventory source with ini plugin Loading collection dellemc.enterprise_sonic from /home/kerry/.ansible/collections/ansible_collections/dellemc/enterprise_sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic Loading callback plugin default of type stdout, v2.0 from /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible/plugins/callback/default.py Skipping callback 'default', as we already have a stdout callback. Skipping callback 'minimal', as we already have a stdout callback. Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: intf_cfg_jguilford.yaml ************************************************************************************** Positional arguments: /home/kerry/playbooks/intf_cfg_jguilford.yaml verbosity: 4 connection: ssh become_method: sudo tags: ('all',) inventory: ('/home/kerry/v2.4.0_clone/dellemc.enterprise_sonic/tests/regression/hosts',) forks: 5 1 plays in /home/kerry/playbooks/intf_cfg_jguilford.yaml

PLAY [Configure Host interface parameters] ***************************************************************************** redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic Loading collection ansible.netcommon from /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible_collections/ansible/netcommon

TASK [sonic base interface configuration] ****************************************************************************** task path: /home/kerry/playbooks/intf_cfg_jguilford.yaml:17 redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi Loading collection ansible.utils from /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible_collections/ansible/utils redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic <100.94.113.38> attempting to start connection <100.94.113.38> using connection plugin ansible.netcommon.httpapi Found ansible-connection at path /home/kerry/.py11venv/bin/ansible-connection <100.94.113.38> local domain socket does not exist, starting it <100.94.113.38> control socket path is /home/kerry/.ansible/pc/98f6ba4649 <100.94.113.38> Loading collection ansible.builtin from <100.94.113.38> redirecting (type: connection) ansible.builtin.httpapi to ansible.netcommon.httpapi <100.94.113.38> Loading collection ansible.netcommon from /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible_collections/ansible/netcommon <100.94.113.38> Loading collection ansible.utils from /home/kerry/.py11venv/lib64/python3.11/site-packages/ansible_collections/ansible/utils <100.94.113.38> Loading collection dellemc.enterprise_sonic from /home/kerry/.ansible/collections/ansible_collections/dellemc/enterprise_sonic <100.94.113.38> local domain socket listeners started successfully <100.94.113.38> loaded API plugin ansible_collections.dellemc.enterprise_sonic.plugins.httpapi.sonic from path /home/kerry/.ansible/collections/ansible_collections/dellemc/enterprise_sonic/plugins/httpapi/sonic.py for platform type dellemc.enterprise_sonic.sonic <100.94.113.38> Loading collection ansible.builtin from <100.94.113.38> local domain socket path is /home/kerry/.ansible/pc/98f6ba4649 redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic <100.94.113.38> ANSIBLE_NETWORK_IMPORT_MODULES: enabled <100.94.113.38> ANSIBLE_NETWORK_IMPORT_MODULES: found sonic_interfaces at /home/kerry/.ansible/collections/ansible_collections/dellemc/enterprise_sonic/plugins/modules/sonic_interfaces.py <100.94.113.38> ANSIBLE_NETWORK_IMPORT_MODULES: running sonic_interfaces <100.94.113.38> ANSIBLE_NETWORK_IMPORT_MODULES: complete changed: [sonic1] => { "after": [ { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/1", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/10", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/11", "speed": "SPEED_400GB" }, { "description": "path to some server", <<< "enabled": true, <<< "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/12", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/13", "speed": "SPEED_400GB" }, * * * } ], "before": [ { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/1", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/10", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/11", "speed": "SPEED_400GB" }, { "enabled": false, <<< (and no 'description') "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/12", "speed": "SPEED_400GB" }, { "enabled": false, "fec": "FEC_RS", "mtu": 9100, "name": "Eth1/13", "speed": "SPEED_400GB" }, * * * } ], "changed": true, "commands": [ { "description": "path to some server", "enabled": true, "name": "Eth1/12", "state": "merged" } ], "invocation": { "module_args": { "config": [ { "advertised_speed": null, "auto_negotiate": null, "description": "path to some server", "enabled": true, "fec": null, "mtu": null, "name": "Eth1/12", "speed": null } ], "state": "merged" } } }

PLAY RECAP ************************************************************************************************************* sonic1 : ok=1 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0

(.py11venv) kerry@opensuse155:~/v2.4.0_clone/dellemc.enterprise_sonic>

kerry-meyer avatar Jul 28 '24 21:07 kerry-meyer

No response or additional information has been posted on this Issue since the posting of a demonstration that the functionality (playbook) described works correctly for the specified version of the enterprise_sonic Ansible resource module collection running against the specified SONiC release image from a server with the necessary software configuration and settings.

I am closing the Issue because without additional information including, at least, the items requested near the top of my previous posting for this Issue, we can take no further action on the Issue.

kerry-meyer avatar Aug 08 '24 00:08 kerry-meyer