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

[QUESTION]: Command module working ok but others fail #489

Open
msmithaxesssystemscouk opened this issue Nov 29, 2024 · 1 comment
Open

Comments

@msmithaxesssystemscouk
Copy link

The config modules are all failing for me but the command module works ok.

I have run the sample playbook below to set the hostname for a switch and it fails as shown below. I get the same error with other modules, eg ntp, l2_interface, vrfs, but the sonic_command module works fine for me.

- name: Merge provided configuration with device configuration
  dellemc.enterprise_sonic.sonic_system:
    config:
      hostname: SONIC
      interface_naming: standard
      anycast_address:
        ipv6: true
        ipv4: true
        mac_address: aa:bb:cc:dd:ee:ff
      load_share_hash_algo: JENKINS_HASH_HI
    state: merged
The full traceback is:
  File "/home/mike/.ansible/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/facts/system/system.py", line 53, in get_system
    response = edit_config(self._module, to_request(self._module, request))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mike/.ansible/collections/ansible_collections/dellemc/enterprise_sonic/plugins/module_utils/network/sonic/sonic.py", line 140, in edit_config
    return connection.edit_config(commands)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/ansible/module_utils/connection.py", line 199, in __rpc__
    raise ConnectionError(to_text(msg, errors='surrogate_then_replace'), code=code)
fatal: [lab-sonic-01]: FAILED! => changed=false
  code: -32603
  invocation:
    module_args:
      config:
        anycast_address:
          ipv4: true
          ipv6: true
          mac_address: aa:bb:cc:dd:ee:ff
        audit_rules: null
        auto_breakout: null
        hostname: SONIC
        interface_naming: standard
        load_share_hash_algo: JENKINS_HASH_HI
      state: merged
  msg: '''command'''
...ignoring

But the following works fine -

    - name: T.01 Save Config
      dellemc.enterprise_sonic.sonic_command:
        commands: 
          - write me

    - name: T.02 Gather Audit Info
      dellemc.enterprise_sonic.sonic_command:
        commands: 
          - show clock
          - show system
          - show image list

Output -

ok: [lab-sonic-01] => changed=false
  invocation:
    module_args:
      commands:
      - write me
      interval: 1
      match: all
      retries: 10
      wait_for: null
  stdout:
  - write memory
  stdout_lines: <omitted>
redirecting (type: action) dellemc.enterprise_sonic.sonic_command to dellemc.enterprise_sonic.sonic

ok: [lab-sonic-01] => changed=false
  invocation:
    module_args:
      commands:
      - show clock
      - show system
      - show image list
      interval: 1
      match: all
      retries: 10
      wait_for: null
  stdout:
  - Fri 29 Nov 2024 03:45:45 PM UTC
  - |-
    -----------------------------------------------------------
    Attribute            Value/State
    -----------------------------------------------------------
    Boot Time           :02:18:43
    Current Datetime    :2024-11-29T15:45:45Z
    Hostname            :lab-sonic
  - |-
    Current: SONiC-OS-4.2.0-Enterprise_Base
    Next: SONiC-OS-4.2.0-Enterprise_Base
    Available:
    SONiC-OS-4.2.0-Enterprise_Base
  - |-

I have tested this with

dellemc.enterprise_sonic 3.0.0

and SONiC versions 4.2.0 and 4.4.0,

@ArunSaravananBalachandran
Copy link
Collaborator

Depending on the module being used, the ansible connection type can either be 'network_cli' (for CLI command modules such as sonic_command, sonic_config) or 'httpapi'.

For the ansible connection type in the playbook with 'sonic_system', please use "httpapi" instead of "network_cli".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants