### Retrieve Network Instances using get Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Example of using the `get` method to retrieve network instance data. The `command` parameter specifies the API path. ```python status, vlans = api.get('data/openconfig-network-instance:network-instances') ``` -------------------------------- ### Example Usage of sonic_mgmt_servers Module Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_mgmt_servers_module.rst This example demonstrates how to use the sonic_mgmt_servers module with the 'merged' state to configure telemetry server settings. It shows the state of the configuration before applying the module. ```yaml # Using "merged" state # # Before state: # - - - - - - - - - - - - - - - - - - - - - - - - - # # sonic# show ip rest # # Log level is 0 # Port is 443 # Request limit is not-set # Read timeout is 15 seconds ``` -------------------------------- ### Get Image Installation Status Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst Retrieves the current status of the image installation process. ```yaml - name: Get image installation status dellemc.enterprise_sonic.sonic_image_management: image: command: get-status ``` -------------------------------- ### Example: Using 'merged' state for MAC table entries Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_mac_module.rst This example demonstrates how to add or update a MAC table entry using the 'merged' state. Ensure the necessary parameters like interface, mac_address, and vlan_id are provided. ```yaml - name: Add a static MAC entry dellemc.enterprise_sonic.sonic_mac_module: interface: Ethernet0 mac_address: 00:11:22:33:44:55 vlan_id: 10 state: merged ``` -------------------------------- ### Install Collection from Local Source Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/wiki/Installation-of-the-latest-pre-release-version Install the Ansible collection using the local source path defined in requirements.yml. Use --force if updating or re-installing. ```bash ansible-galaxy collection install -r ./requirements.yml [--force] ``` -------------------------------- ### Get Startup Configuration (CLICONF) Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Retrieves the startup configuration from the device. Use this to inspect the configuration that will be loaded on reboot. ```python # Get startup configuration config = conn.get_config(source='startup') ``` -------------------------------- ### Get Device Capabilities Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Example response format for retrieving device capabilities. The `get_capabilities()` method returns this information as a JSON string. ```json { "rpc": [], "network_api": "sonic_rest" } ``` -------------------------------- ### Example: Delete OSPFv3 Configuration Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospfv3_module.rst This example demonstrates how to use the `state: deleted` option to remove an existing OSPFv3 configuration from a SONiC device. Ensure the VRF name and other relevant parameters match the configuration to be deleted. ```yaml - name: Delete OSPFv3 configuration dellemc.enterprise_sonic.sonic_ospfv3: vrf_name: "{{ vrf_name }}" state: "deleted" ``` -------------------------------- ### Configure Logging with Console and Remote Servers Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/configuration-options.md Example of configuring both console and remote syslog server logging. It shows how to set severity levels for each. ```yaml - name: Configure logging dellemc.enterprise_sonic.sonic_logging: config: console: enabled: true severity: WARNING remote_servers: - server_address: 192.168.1.100 port: 514 severity: INFO - server_address: 192.168.1.101 severity: DEBUG state: merged ``` -------------------------------- ### Prepare Module Parameters for API Request Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/module-utils.md This example demonstrates how to use to_request to prepare module parameters for an API request, which can then be passed to edit_config. ```python requests = to_request(module, [module.params]) responses = edit_config(module, requests) ``` -------------------------------- ### Get List of Installed Images Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst Fetches a list of all images currently installed on the device. ```yaml - name: Get list of installed images dellemc.enterprise_sonic.sonic_image_management: image: command: get-list ``` -------------------------------- ### Configure QoS Buffer Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_qos_buffer_module.rst This example shows how to configure QoS buffer settings, including initializing the buffer and defining buffer pools with specific configurations. ```APIDOC ## configure QoS Buffer ### Description Configures QoS buffer settings on SONiC devices. This includes initializing the buffer with system defaults and defining buffer pools with specific parameters like `name` and `xoff`. ### Parameters #### config (dictionary) QoS buffer configuration. ##### buffer_init (boolean) Initialize QoS buffer based on system defaults. Buffer must be initialized to configure `buffer_pools` and `buffer_profiles`. (added in 3.0.0) Choices: - no - yes ##### buffer_pools (list of dictionaries) Buffer pools configuration. ###### name (string) - Required Name of buffer pool. Choices: - ingress_lossless_pool ###### xoff (integer) Amount of shared buffer space in bytes, must be less than pool size. Required non-key attribute. ``` -------------------------------- ### Show Running Configuration OSPF Example Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospf_area_module.rst This snippet displays a sample output of the 'show running-configuration ospf' command, illustrating the configuration of OSPF areas, virtual links, ranges, and authentication settings as they would appear on a SONIC device. ```text router ospf vrf Vrf1 area 0.0.0.2 authentication message-digest area 0.0.0.2 stub no-summary area 0.0.0.2 default-cost 3 area 0.0.0.2 shortcut default area 0.0.0.3 filter-list prefix pf1 in area 0.0.0.3 filter-list prefix pf2 out area 0.0.0.4 area 0.0.0.5 area 0.0.0.5 virtual-link 34.7.35.1 area 0.0.0.5 virtual-link 34.7.35.2 area 0.0.0.5 virtual-link 34.7.35.2 authentication area 0.0.0.5 virtual-link 34.7.35.2 authentication-key U2FsdGVkX197YJtZ/3Ac6n5kRIG/ZqeU1/wC0cVFyfU= encrypted area 0.0.0.5 virtual-link 34.7.35.2 dead-interval 30 area 0.0.0.5 virtual-link 34.7.35.2 hello-interval 10 area 0.0.0.5 virtual-link 34.7.35.2 retransmit-interval 40 area 0.0.0.5 virtual-link 34.7.35.2 transmit-delay 50 area 0.0.0.5 virtual-link 34.7.35.2 message-digest-key 1 md5 U2FsdGVkX1/wbqjMB7Lr+Mm3wY8+lCdaqUmG2rr9Adw= encrypted area 0.0.0.5 virtual-link 34.7.35.2 message-digest-key 2 md5 U2FsdGVkX18Czj9r8skDrg/wtpwTKKCQ8FXUehpCmHc= encrypted area 0.0.0.3 range 1.1.1.1/24 area 0.0.0.3 range 1.1.1.2/24 advertise cost 4 area 0.0.0.3 range 1.1.1.3/24 not-advertise area 0.0.0.3 range 1.1.1.4/24 advertise cost 10 area 0.0.0.3 range 1.1.1.4/24 substitute 3.3.3.3/24 network 1.1.1.1/24 area 0.0.0.4 network 23.235.75.1/23 area 0.0.0.4 network 3.5.1.5/23 area 0.0.0.4 ! router ospf vrf Vrf2 ! ``` -------------------------------- ### Configuration with Parent and Lines Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_config_module.rst This example demonstrates applying configuration lines under a specific parent context. The 'parents' argument specifies the hierarchy, and 'lines' provides the configuration statements. ```yaml - dellemc.enterprise_sonic.sonic_config: lines: - description 'SONiC' parents: ['interface Eth1/10'] ``` -------------------------------- ### Install Specific Enterprise SONiC Collection Version Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Install a specific version range of the delllemc.enterprise_sonic collection from Ansible Galaxy, for example, versions greater than or equal to 1.0.0 and less than 2.0.0. ```bash ansible-galaxy collection install 'dellemc.enterprise_sonic:>=1.0.0,<2.0.0' ``` -------------------------------- ### Configure OSPF Area with Ranges, Networks, and Virtual Links Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospf_area_module.rst This example demonstrates configuring an OSPF area with various sub-options including ranges, networks, and virtual links. It shows how to set advertise, cost, substitute, and authentication details for ranges and virtual links. ```yaml - area_id: 4 vrf_name: Vrf1 networks: - 1.1.1.1/24 - 3.5.1.5/23 - 23.235.75.1/23 - area_id: 5 vrf_name: Vrf1 virtual_links: - router_id: 34.7.35.1 enabled: true - router_id: 34.7.35.2 enabled: true dead_interval: 30 hello_interval: 10 retransmit_interval: 40 transmit_delay: 50 authentication: auth_type: text key: "U2FsdGVkX197YJtZ/3Ac6n5kRIG/ZqeU1/wC0cVFyfU=" key_encrypted: true message_digest_list: - key_id: 1 key: "U2FsdGVkX1/wbqjMB7Lr+Mm3wY8+lCdaqUmG2rr9Adw=" key_encrypted: true - key_id: 2 key: "U2FsdGVkX18Czj9r8skDrg/wtpwTKKCQ8FXUehpCmHc=" key_encrypted: true ``` -------------------------------- ### Install Ansible Collection from Galaxy Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/README.md Installs the dell-enterprise-sonic Ansible collection using ansible-galaxy. This is the recommended method for installing the collection. ```bash # Install from Galaxy ansible-galaxy collection install dellemc.enterprise_sonic ``` -------------------------------- ### get Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Performs a GET request to retrieve data from a specified API path. ```APIDOC ## get(command) ### Description Performs GET request to retrieve data. ### Parameters #### Path Parameters - **command** (str) - API path for GET request ### Returns - tuple: `(status_code, response_data)` ### Example ```python status, vlans = api.get('data/openconfig-network-instance:network-instances') ``` ``` -------------------------------- ### Install Enterprise SONiC Image Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst Use this snippet to install a SONiC image from a local file path. ```yaml - name: Install Enterprise SONiC image dellemc.enterprise_sonic.sonic_image_management: image: command: install path: 'file://home/admin/sonic.bin' ``` -------------------------------- ### VLAN Configuration using CLICONF Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Sample playbook demonstrating VLAN configuration using the sonic_config module with network_cli connection. It registers the output of the configuration command and then executes a 'show vlan' command. ```yaml --- - name: SONiC Management Framework CLI configuration examples hosts: sonic_switches gather_facts: no connection: network_cli tasks: - name: Add VLAN entry dellemc.enterprise_sonic.sonic_config: commands: ['interface Vlan 700','exit'] save: yes register: config_op - name: Test SONiC single command dellemc.enterprise_sonic.sonic_command: commands: 'show vlan' register: cmd_op ``` -------------------------------- ### Install Latest Enterprise SONiC Collection Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Install the latest version of the delllemc.enterprise_sonic collection from Ansible Galaxy. ```bash ansible-galaxy collection install dellemc.enterprise_sonic ``` -------------------------------- ### Create Users with Roles and SSH Keys Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/configuration-options.md This example demonstrates creating users with specified roles and optionally associating SSH public keys for authentication. Passwords should be managed securely using vault in production. ```yaml - name: Create users dellemc.enterprise_sonic.sonic_users: config: - name: admin password: "{{ admin_password }}" role: admin ssh_key: "{{ ssh_public_key }}" - name: readonly role: user state: merged ``` -------------------------------- ### Collect VLAN and interfaces facts Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_facts_module.rst This example demonstrates collecting specific network resources like VLANs and interfaces, along with a minimal set of default facts. ```yaml - name: Collects VLAN and interfaces facts dellemc.enterprise_sonic.sonic_facts: gather_subset: - min gather_network_resources: - vlans - interfaces ``` -------------------------------- ### Retrieve Interface Configuration (GET) Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/core-modules.md Checks that you can connect to a page by retrieving interface configuration using a GET request. ```yaml - name: Checks that you can connect (GET) to a page dellemc.enterprise_sonic.sonic_api: url: data/openconfig-interfaces:interfaces/interface=Ethernet60 method: "GET" status_code: 200 ``` -------------------------------- ### Collect VLAN and minimal default facts Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_facts_module.rst This example shows how to gather a specific network resource (VLANs) along with the minimal set of default facts. ```yaml - name: Collects VLAN and minimal default facts dellemc.enterprise_sonic.sonic_facts: gather_subset: min gather_network_resources: vlans ``` -------------------------------- ### GET Request - Retrieve Interface Configuration Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/core-modules.md Retrieves the configuration for a specific interface using a GET request to the sonic_api module. ```APIDOC ## GET /data/openconfig-interfaces:interfaces/interface=Ethernet60 ### Description Retrieves the configuration for a specific interface. ### Method GET ### Endpoint data/openconfig-interfaces:interfaces/interface=Ethernet60 ### Parameters #### Query Parameters - **url** (string) - Required - The API endpoint to retrieve data from. - **method** (string) - Required - The HTTP method to use, which is 'GET' in this case. - **status_code** (integer) - Required - The expected HTTP status code for a successful response, which is 200. ``` -------------------------------- ### Manage Firmware Updater Installation Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst This section details how to manage the installation of firmware updaters using the `firmware` parameter within the `sonic_image_management` module. ```APIDOC ## Manage Firmware Updater Installation ### Description Manages the installation of Firmware updaters. ### Parameters #### Request Body - **firmware** (dictionary) - Manages installation of Firmware updater. - **command** (string) - Required - Specifies the firmware updater management operation to be performed. Choices: `install`, `cancel`, `get-list`, `get-status`. - **path** (string) - Optional - When `command=install`, specifies the path of the firmware updater to be staged. Path can be a file in the device (file://filepath) or URL (http:// or https://). ``` -------------------------------- ### Configure PKI with 'present' state Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_pki_module.rst Use the 'present' state to ensure a specific PKI configuration exists. This example configures a trust store and a security profile. ```yaml - name: "Present Config" dellemc.enterprise_sonic.sonic_pki: config: security_profiles: - profile_name: telemetry ocsp_responder_list: - http://example.com/ocspb revocation_check: true trust_store: telemetry-ts certificate_name: host trust_stores: - name: telemetry-ts ca_name: CA state: present ``` -------------------------------- ### Install Ansible Collection from Source Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/README.md Installs the dell-enterprise-sonic Ansible collection directly from its source repository. This method is useful for development or testing purposes. ```bash # Or from source git clone https://github.com/ansible-collections/dellemc.enterprise_sonic.git cd dellemc.enterprise_sonic ansible-galaxy collection install . ``` -------------------------------- ### Install GPG Key for Image Verification Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst Installs a GPG public key for verifying image authenticity. Requires keyserver and public key ID. ```yaml - name: Install GPG Key for image verification dellemc.enterprise_sonic.sonic_image_management: image: command: gpg-key keyserver: 'hkp://keyserver.ubuntu.com:80' pubkeyid: 'DAFWQGEW12345678' ``` -------------------------------- ### Manage SONiC Image Installation Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst This section details how to manage the installation of Enterprise SONiC images using the `image` parameter within the `sonic_image_management` module. ```APIDOC ## Manage SONiC Image Installation ### Description Manages the installation of Enterprise SONiC images. ### Parameters #### Request Body - **image** (dictionary) - Required - Manages installation of Enterprise SONiC image. - **command** (string) - Required - Specifies the image management operation to be performed. Choices: `install`, `cancel`, `get-list`, `get-status`. ``` -------------------------------- ### Merge OSPFv3 Interface Configurations Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospfv3_interfaces_module.rst This example demonstrates how to merge OSPFv3 interface configurations. This allows adding new configurations or updating existing ones without overwriting unrelated settings. ```APIDOC ## Merge OSPFv3 Interface Configurations ### Description This operation merges OSPFv3 configurations for specified interfaces. New configurations are added, and existing ones are updated. ### Method `sonic_ospfv3_interfaces` module with `state: merged` ### Parameters #### Config - **name** (string) - Required - The name of the interface. - **advertise** (string) - Optional - Advertise prefix list. - **area_id** (string) - Optional - The OSPFv3 area ID. - **cost** (int) - Optional - The OSPFv3 interface cost. - **passive** (bool) - Optional - Set interface as passive. - **priority** (int) - Optional - The OSPFv3 interface priority. - **hello_interval** (int) - Optional - The OSPFv3 hello interval. - **dead_interval** (int) - Optional - The OSPFv3 dead interval. - **mtu_ignore** (bool) - Optional - Ignore MTU. - **hello_multiplier** (int) - Optional - The OSPFv3 hello multiplier. - **bfd** (dict) - Optional - BFD configuration. - **enable** (bool) - Required - Enable BFD. - **bfd_profile** (string) - Optional - The BFD profile name. - **network** (string) - Optional - The OSPFv3 network type (e.g., 'broadcast', 'point_to_point'). ### Request Example ```yaml - name: Add the OSPFv3_interface configurations sonic_ospfv3_interfaces: config: - name: 'Eth1/1' advertise: 'test1' area_id: '2.2.2.2' cost: 20 passive: true priority: 20 hello_interval: 10 dead_interval: 40 mtu_ignore: true hello_multiplier: 5 bfd: enable: true bfd_profile: 'profile1' network: broadcast - name: 'Eth1/3' area_id: '3.3.3.3' hello_multiplier: 5 bfd: enable: true network: point_to_point state: merged ``` ``` -------------------------------- ### State Management Examples Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/configuration-options.md Illustrates different states for managing configuration items. Use 'merged' to add/modify, 'replaced' to update and remove unspecified, 'overridden' to clear sections, and 'deleted' to remove specific items. ```yaml # Add/modify state: merged # Update and remove unspecified state: replaced # Clear entire section state: overridden # Remove specific item state: deleted ``` -------------------------------- ### Configure NTP Server Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/resource-modules.md Manage NTP configuration with the sonic_ntp module. This example adds an NTP server with a specific IP address, port, key ID, and version. ```yaml config: - server_address: "10.0.0.1" port: 123 key_id: 1 version: 4 state: merged ``` -------------------------------- ### Send GET Request using send_request Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Demonstrates how to perform a GET request to retrieve interface data using the `send_request` method. Ensure `api` object is initialized. ```python # GET request status, data = api.send_request( data=None, path='data/openconfig-interfaces:interfaces', method='get' ) ``` -------------------------------- ### Configure VLANs using Resource Modules Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Sample playbook demonstrating VLAN configuration using the sonic_vlans resource module. It configures multiple VLANs with the state set to 'merged'. ```yaml - name: Configure VLANs dellemc.enterprise_sonic.sonic_vlans: config: - vlan_id: 701 - vlan_id: 702 - vlan_id: 703 - vlan_id: 704 state: merged register: sonic_vlans_output ``` -------------------------------- ### Install Specific Version of Ansible Collection Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/README.md Installs a specific version range of the dell-enterprise-sonic Ansible collection from Ansible Galaxy. This is useful for ensuring compatibility with specific project requirements. ```bash # Or specify version ansible-galaxy collection install 'dellemc.enterprise_sonic:>=4.1.0,<5.0.0' ``` -------------------------------- ### Basic Configuration with Lines Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_config_module.rst Use this snippet to apply a single line of configuration. Ensure the 'lines' parameter is correctly formatted. ```yaml - dellemc.enterprise_sonic.sonic_config: lines: ['username {{ user_name }} password {{ user_password }} role {{ user_role }}'] ``` -------------------------------- ### Edit Configuration via REST API (GET) Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/module-utils.md Use this snippet to send a REST API GET request. The function automatically handles URL encoding for interface names. ```python requests = [{ 'path': 'data/openconfig-interfaces:interfaces/interface=Eth1/1', 'method': 'GET' }] responses = edit_config(module, requests) ``` -------------------------------- ### Configure OSPF Area with Ranges and Advertise Options Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospf_area_module.rst This example configures an OSPF area with specific ranges, including options to advertise or not advertise, set costs, and define substitute prefixes. It's useful for granular control over route advertisement within an area. ```yaml - area_id: 3 vrf_name: Vrf1 ranges: - prefix: 1.1.1.1/24 - prefix: 1.1.1.2/24 advertise: true cost: 4 - prefix: 1.1.1.3/24 advertise: false - prefix: 1.1.1.4/24 advertise: true cost: 10 substitute: 3.3.3.3/24 ``` -------------------------------- ### OSPF Area Configuration Example Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospf_area_module.rst This example demonstrates a complex OSPF area configuration with virtual links, ranges, and authentication details. It is used to define OSPF behavior within a specific VRF. ```yaml - 23.235.75.1/23 - area_id: 3 vrf_name: Vrf1 virtual_links: - router_id: 34.7.35.1 enabled: true transmit_delay: 50 hello_interval: 30 authentication: auth_type: text key: "U2FsdGVkX18zN46d3pzk+t7TofEHAZGY+5RvgXMwDiQ=" key_encrypted: true ranges: - prefix: 1.1.1.1/24 advertise: true substitute: 11.2.5.1/24 - prefix: 1.1.1.2/24 advertise: true cost: 4 - prefix: 1.1.1.3/24 advertise: true substitute: 2.5.3.78/24 - area_id: 4 vrf_name: Vrf1 shortcut: default virtual_links: - router_id: 34.7.35.1 enabled: true transmit_delay: 50 hello_interval: 30 authentication: auth_type: text key: "U2FsdGVkX18zN46d3pzk+t7TofEHAZGY+5RvgXMwDiQ=" key_encrypted: true - router_id: 34.7.35.2 transmit_delay: 50 enabled: true dead_interval: 10 retransmit_interval: 40 message_digest_list: - key_id: 1 key: "U2FsdGVkX18mUZjlJL/Q/7vYtx2UyDc+NcLKc/BOJUA=" key_encrypted: true - key_id: 3 key: "U2FsdGVkX19SlRpqsnpeRmjq7WmtctYtveHlYF0Faqo=" key_encrypted: true authentication: auth_type: message_digest key: "U2FsdGVkX18zN46d3pzk+t7TofEHAZGY+5RvgXMwDiQ=" key_encrypted: true ``` -------------------------------- ### Configure Layer 2 Interfaces using Resource Modules Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Sample playbook demonstrating Layer 2 interface configuration using the sonic_l2_interfaces resource module. It configures access and trunk ports with specific VLANs, setting the state to 'merged'. ```yaml - name: Configure Layer 2 interfaces dellemc.enterprise_sonic.sonic_l2_interfaces: config: - name: Eth1/2 access: vlan: 701 trunk: allowed_vlans: - vlan: 702 - vlan: 703 state: merged register: sonic_l2_interfaces_output ``` -------------------------------- ### Run show version command via CLI Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Example of using the `sonic_command` module to execute a 'show version' command on a SONiC device via network_cli connection. ```yaml - name: SONiC device configuration via CLI hosts: sonic_devices gather_facts: no connection: network_cli tasks: - name: Run command dellemc.enterprise_sonic.sonic_command: commands: show version ``` -------------------------------- ### Merge STP Configurations Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_stp_module.rst Use the 'merged' state to apply STP configurations. This example demonstrates setting global STP parameters, interface-specific options, and MSTP configurations. Ensure the module is configured with the desired parameters and the target state. ```yaml - name: Merge STP configurations dellemc.enterprise_sonic.sonic_stp: config: global: enabled_protocol: mst loop_guard: true bpdu_filter: true disabled_vlans: - 4-6 hello_time: 5 max_age: 10 fwd_delay: 20 bridge_priority: 4096 interfaces: - intf_name: Ethernet20 edge_port: true link_type: shared guard: loop bpdu_guard: true bpdu_filter: true uplink_fast: true shutdown: true cost: 20 port_priority: 30 stp_enable: true mstp: mst_name: mst1 revision: 1 max_hop: 3 hello_time: 6 max_age: 9 fwd_delay: 12 mst_instances: - mst_id: 1 bridge_priority: 2048 vlans: - 1 interfaces: - intf_name: Ethernet20 cost: 60 port_priority: 65 state: merged ``` -------------------------------- ### Add OSPFv3 Configurations (Merged Example 1) Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_ospfv3_module.rst Use this snippet to add OSPFv3 configurations using the 'merged' state. It configures settings for both the 'default' VRF (router ID, distance) and 'Vrf_1' (timers, redistribution with route-map). ```yaml - name: Add the OSPFv3 configurations sonic_ospfv3: config: - vrf_name: 'default' router_id: "10.10.10.10" distance: external: 20 - vrf_name: "Vrf_1" timers: throttle_spf: delay_time: 10 initial_hold_time: 20 maximum_hold_time: 50 redistribute: - protocol: "bgp" metric: 15 metric_type: 2 route_map: "RMAP" state: merged ``` -------------------------------- ### Stage a Firmware Updater Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_image_management_module.rst Stages a firmware updater package for potential installation. ```yaml - name: Stage a firmware updater dellemc.enterprise_sonic.sonic_image_management: firmware: command: install path: 'file://home/admin/onie-update-full.bin' ``` -------------------------------- ### Get Running Configuration (CLICONF) Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/_autodocs/plugins.md Retrieves the current running configuration from the device. This is the default behavior when no source is specified. ```python # Get running configuration config = conn.get_config() ``` -------------------------------- ### VLAN Configuration using HTTPAPI Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/README.md Sample playbook demonstrating VLAN configuration using the sonic_api module with httpapi connection. It performs a PUT operation to add a network instance and a GET operation to view it. ```yaml --- - name: SONiC Management Framework REST API examples hosts: sonic_switches gather_facts: no connection: httpapi tasks: - name: Perform PUT operation to add a VLAN network instance dellemc.enterprise_sonic.sonic_api: url: data/openconfig-network-instance:network-instances/network-instance=Vlan100 method: "PUT" body: {"openconfig-network-instance:network-instance": [{"name": "Vlan100","config": {"name": "Vlan100"}}]}, status_code: 204 - name: Perform GET operation to view VLAN network instance dellemc.enterprise_sonic.sonic_api: url: data/openconfig-network-instance:network-instances/network-instance=Vlan100 method: "GET" status_code: 200 register: api_op ``` -------------------------------- ### Delete a VXLAN configuration Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_vxlans_module.rst Use the 'deleted' state to remove a VXLAN configuration. This example shows the state before and after the operation. ```yaml - name: "Test vxlans deleted state 01" dellemc.enterprise_sonic.sonic_vxlans: config: - name: vteptest1 vlan_name: Vlan12 state: deleted ``` -------------------------------- ### Delete Port Group Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/blob/main/docs/dellemc.enterprise_sonic.sonic_port_group_module.rst Example of deleting a port group configuration. This action will remove the specified port group. ```yaml --- - name: Delete port group dellemc.enterprise_sonic.sonic_port_group: config: - id: 1 state: deleted ``` -------------------------------- ### Run Unit and Coverage Tests Natively Source: https://github.com/ansible-collections/dellemc.enterprise_sonic/wiki/Running-Sanity-Tests,-Unit-Tests,-and-Coverage-Report-Generation Execute unit and coverage tests using a native package installation. Ensure requirements are met and enable coverage reporting. The output of the coverage report can be piped to a file. ```bash ansible-test units --python `python version` --coverage --requirements ``` ```bash ansible-test coverage report | tee ```