ansible-collections / dellemc.enterprise_sonic

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

[QUESTION]:(Error)Is socket_path a required parameter for the sonic_api module? If so, how should it be set? #488

Open DelDex opened 3 days ago

DelDex commented 3 days ago

Playbook Example This is the task I ran:

What I Expect The VLAN should be added to the device without errors, and the API should return a success status.

What Happens The task fails with the following error:

msg: socket_path must be a value

Questions

1)Is socket_path a required parameter for the sonic_api module? If so, how should it be set? 2)The documentation does not mention socket_path. Could you clarify its purpose and provide guidance on how to use it correctly? 3)Is there a default value for socket_path, or does it need to be manually specified?

Troubleshooting Steps Tried

Checked the module documentation but found no mention of socket_path. Added socket_path: "/var/run/sonic/api.sock" explicitly, but I'm unsure if this is the correct value for my setup.

ArunSaravananBalachandran commented 1 day ago

The ansible connection type determines the value of 'socket_path'.

Depending on the module being used, the ansible connection type can either be 'network_cli' (for CLI commands) or 'httpapi'. For sonic_api the connection type is 'httpapi'.

Example:

---
- hosts: device1
  connection: httpapi
  tasks:
    - name: sonic_api example
      dellemc.enterprise_sonic.sonic_api:
        url: "data/openconfig-interfaces:interfaces/interface=Vlan100"
        method: "GET"
        status_code: 200