ansible-collections / dellemc.enterprise_sonic

Ansible Network Collection for Enterprise SONiC Distribution by Dell Technologies
GNU General Public License v3.0
44 stars 64 forks source link

Getting error while making interfaces up or down using module dellemc.enterprise_sonic.sonic_interfaces: {"changed": false, "code": -32603, "msg": "'command'"} #397

Closed shoneslab closed 4 months ago

shoneslab commented 5 months ago

Bug Description

I am trying make the sonic ethernet interfaces interfaces up/down using the module and getting the error:

Playbook

---
- name: Manage Sonic Switch Interfaces
  hosts: vault_cleanroom_switches
  gather_facts: no
  collections:
    - dellemc.enterprise_sonic

  tasks:
     - name: Set interface down
      dellemc.enterprise_sonic.sonic_interfaces:
        config:
          - name: Ethernet12
            enabled: True
        state: replaced

Inventory File

all:
  children:
    vault_cleanroom_switches:
      hosts:
        sonic_switch_01:
          ansible_host: 192.168.60.2
          ansible_user: admin
          ansible_password: YourPaSsWoRd
          ansible_connection: network_cli
          ansible_network_os: dellemc.enterprise_sonic.sonic

Product Name

Dell Enterprise Sonic Ansible Module

Component or Module Name

dellemc.enterprise_sonic.sonic_interfaces

DellEMC Enterprise SONiC Ansible Collection Version

v2.4.0

SONiC Software Version

Enterprise Sonic 4.2.1 on GNS3 2.2.47

Configuration

ansible version

ansible [core 2.17.0]
  config file = /opt/automation/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.12/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections:/opt/automation/collections
  executable location = /usr/bin/ansible
  python version = 3.12.3 (main, Apr 18 2024, 07:52:31) [GCC 13.2.1 20240309] (/usr/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Steps to Reproduce

Execute the playbook.

Expected Behavior

Playbook should exit successfully by making the interface enabled with status up

Actual Behavior

TASK [Set interface down] ****************************************************************************************************************************************
fatal: [sonic_switch_01]: FAILED! => {"changed": false, "code": -32603, "msg": "'command'"}

Logs

ansible-playbook -i inventory/ playbooks/airgap-management.yml 

PLAY [Manage Sonic Switch Interfaces] ****************************************************************************************************************************

TASK [Set interface down] ****************************************************************************************************************************************
fatal: [sonic_switch_01]: FAILED! => {"changed": false, "code": -32603, "msg": "'command'"}

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

Screenshots

No response

Additional Information

No response

kerry-meyer commented 5 months ago

Hi Shone,

Please send the output from running the failing playbook in 'verbose' mode.

e.g.

ansible-playbook -i \<inventory file path> \<playbook path> -vvvv

                              Kerry Meyer
shoneslab commented 4 months ago

TASK [Set interface down] ** task path: /opt/automation/playbooks/airgap-management.yml:25 redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli redirecting (type: connection) ansible.builtin.network_cli to ansible.netcommon.network_cli redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic redirecting (type: action) dellemc.enterprise_sonic.sonic_interfaces to dellemc.enterprise_sonic.sonic The full traceback is: File "/opt/automation/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/facts/interfaces/interfaces.py", line 55, in get_all_interfaces response = edit_config(self._module, to_request(self._module, request)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/automation/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/sonic.py", line 139, in edit_config return connection.edit_config(commands) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/ansible/module_utils/connection.py", line 199, in rpc raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code) fatal: [sonic_switch_01]: FAILED! => { "changed": false, "code": -32603, "invocation": { "module_args": { "config": [ { "advertised_speed": null, "auto_negotiate": null, "description": null, "enabled": true, "fec": null, "mtu": null, "name": "Ethernet12", "speed": null } ], "state": "replaced" } }, "msg": "'command'" } The full traceback is: File "/opt/automation/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/facts/interfaces/interfaces.py", line 55, in get_all_interfaces response = edit_config(self._module, to_request(self._module, request)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/automation/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/sonic.py", line 139, in edit_config return connection.edit_config(commands) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.12/site-packages/ansible/module_utils/connection.py", line 199, in rpc raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code) fatal: [sonic_switch_02]: FAILED! => { "changed": false, "code": -32603, "invocation": { "module_args": { "config": [ { "advertised_speed": null, "auto_negotiate": null, "description": null, "enabled": true, "fec": null, "mtu": null, "name": "Ethernet12", "speed": null } ], "state": "replaced" } }, "msg": "'command'" }

kerry-meyer commented 4 months ago

The following two corrections are required for this playbook to make it work as intended:

The resulting revised playbook would look like this:

(Changed and added lines are marked by '<<<' to annotate them.)

---
- name: Manage Sonic Switch Interfaces
  hosts: vault_cleanroom_switches
  gather_facts: no
  connection: httpapi                           <<<  (Add this.)
  collections:
    - dellemc.enterprise_sonic

  tasks:
     - name: Set interface down
        sonic_interfaces:                          <<< correct indentation; shorten to module name
          config:                                       <<< recommended: indent these remaining lines by one more space
          - name: Ethernet12
            enabled: True
          state: replaced
kerry-meyer commented 4 months ago

I am closing this issue because the playbook that generated the problem symptoms had problems in the YAML syntax. With a revised version of an equivalent playbook, the operation executes successfully using the current released version of the Dell enterprise_sonic Ansible resource module collection.