### Example: Merged State Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lag_interfaces_module.rst This example demonstrates using the 'merged' state for configuration. It shows the state of the running configuration before applying changes. ```yaml # Using merged # # Before state: # ------------- # # vios#show running-config | section ^interface # interface Port-channel10 # interface GigabitEthernet0/1 # shutdown # interface GigabitEthernet0/2 # shutdown # interface GigabitEthernet0/3 # shutdown # interface GigabitEthernet0/4 # shutdown ``` -------------------------------- ### Example Rendered Configuration Output Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_static_routes_module.rst This is an example of the output when the `ios_static_routes` module is used with `state: rendered`. It shows the Cisco IOS command format for static routes, including VRF configurations. ```text rendered: - ip route vrf blue 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150 - ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast - ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2 - ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3 - ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6 ``` -------------------------------- ### Replace NTP Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_ntp_global_module.rst This example replaces the current NTP configuration with the settings provided in the 'config' parameter. It's useful for enforcing a specific NTP setup. ```yaml - name: Replace commands with provided configuration cisco.ios.ios_ntp_global: config: broadcast_delay: 22 clock_period: 5 logging: true master: stratum: 4 max_associations: 34 max_distance: 3 min_distance: 10 orphan: 4 state: replaced ``` -------------------------------- ### Parse LLDP Global Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lldp_global_module.rst This example demonstrates parsing LLDP global configuration from a file. ```APIDOC ## Parse LLDP Global Configuration ### Description Parses LLDP global configuration from a provided running configuration string. ### Method `cisco.ios.ios_lldp_global` ### Parameters #### Request Body - **running_config** (str) - Required - The running configuration string to parse. - **state** (str) - Required - Set to 'parsed' to parse the configuration. ### Response #### Success Response (200) - **parsed** (dict) - A dictionary containing the parsed LLDP global configuration. - **enabled** (bool) - Indicates if LLDP is enabled. - **holdtime** (int) - The LLDP hold time in seconds. - **reinit** (int) - The LLDP reinitialization timer in seconds. - **timer** (int) - The LLDP timer in seconds. ### Response Example ```json { "parsed": { "enabled": true, "holdtime": 10, "reinit": 3, "timer": 10 } } ``` ``` -------------------------------- ### Configure Interface with Shutdown Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_interfaces_module.rst This example demonstrates configuring an interface with specific settings and then shutting it down. The 'shutdown' parameter controls the administrative status of the interface. ```yaml - name: "Configure and shutdown GigabitEthernet3" cisco.ios.ios_interfaces: config: - name: GigabitEthernet3 description: "Configured and Overridden by Ansible Network" no_ip_address: true shutdown: true speed: '1000' negotiation: no auto state: present ``` -------------------------------- ### Example Cisco IOS Configuration Commands Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_acl_interfaces_module.rst This snippet shows example commands for configuring network interfaces and access control lists on Cisco IOS devices. It includes commands for interface configuration and removing access control lists. ```text interface GigabitEthernet0/1 no ip access-group 123 out no ipv6 traffic-filter test_v6 out ``` -------------------------------- ### HSRP Configuration Example: Vlan100 Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_hsrp_interfaces_module.rst This example shows how to configure HSRP group 5 on Vlan100, including IP address, timers, priority, preemption, authentication, and tracking. ```text # interface Vlan100 # no ip address # standby bfd # standby delay minimum 100 reload 200 # standby version 2 # standby 5 ip 192.168.1.1 # standby 5 timers 5 15 # standby 5 priority 150 # standby 5 preempt # standby 5 authentication hello_secret # standby 5 name BACKUP_GROUP # standby 5 track 10 decrement 30 ``` -------------------------------- ### Parse OSPF Interface Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_ospf_interfaces_module.rst This example demonstrates how to parse the existing running configuration for OSPF interface settings. ```APIDOC ## POST /api/config/ospf/interfaces ### Description Parses the provided configuration with the existing running configuration to extract OSPF interface settings. ### Method POST ### Endpoint /api/config/ospf/interfaces ### Parameters #### Request Body - **running_config** (string) - Required - The existing running configuration of the device. - **state** (string) - Required - The desired state of the configuration. Use 'parsed' for parsing. ### Request Example ```json { "running_config": "{{ lookup('file', 'parsed.cfg') }}", "state": "parsed" } ``` ### Response #### Success Response (200) - **parsed** (list) - A list of dictionaries, where each dictionary represents an OSPF interface configuration. - **name** (string) - The name of the interface. - **address_family** (list) - A list of address family configurations for the interface. - **afi** (string) - The address family identifier (e.g., 'ipv4', 'ipv6'). - **adjacency** (boolean) - Whether adjacency is enabled. - **cost** (object) - OSPF cost configuration. - **interface_cost** (integer) - The interface cost. - **dead_interval** (object) - OSPF dead interval configuration. - **time** (integer) - The dead interval time. - **demand_circuit** (object) - OSPF demand circuit configuration. - **enable** (boolean) - Whether demand circuit is enabled. - **ignore** (boolean) - Whether to ignore demand circuit settings. - **network** (object) - OSPF network type configuration. - **broadcast** (boolean) - Whether to enable broadcast network type. - **priority** (integer) - The OSPF interface priority. - **process** (object) - OSPF process configuration. - **area_id** (string) - The OSPF area ID. - **id** (integer) - The OSPF process ID. - **resync_timeout** (integer) - The resync timeout value. - **shutdown** (boolean) - Whether the OSPF interface is shut down. - **ttl_security** (object) - OSPF TTL security configuration. - **hops** (integer) - The number of hops for TTL security. - **set** (boolean) - Whether to set TTL security. - **database_filter** (boolean) - Whether database filtering is enabled. - **manet** (object) - OSPF MANET peering configuration. - **link_metrics** (object) - MANET link metrics configuration. - **cost_threshold** (integer) - The link cost threshold. - **transmit_delay** (integer) - The OSPF transmit delay. #### Response Example ```json { "parsed": [ { "name": "GigabitEthernet0/2", "address_family": [ { "adjacency": true, "afi": "ipv4", "bfd": true, "cost": { "interface_cost": 5 }, "dead_interval": { "time": 5 }, "demand_circuit": { "enable": true, "ignore": true }, "network": { "broadcast": true }, "priority": 25, "process": { "area_id": "30", "id": 10 }, "resync_timeout": 10, "shutdown": true, "ttl_security": { "hops": 50, "set": true } }, { "adjacency": true, "afi": "ipv6", "database_filter": true, "manet": { "link_metrics": { "cost_threshold": 10 } }, "priority": 55, "process": { "area_id": "45", "id": 35 }, "transmit_delay": 45 } ] }, { "name": "GigabitEthernet0/1" }, { "name": "GigabitEthernet0/0" } ] } ``` ``` -------------------------------- ### Example Parsed Configuration Output Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_static_routes_module.rst This is an example of the structured data returned when the `ios_static_routes` module is used with `state: parsed`. It details IPv4 and IPv6 routes with their respective next-hop information. ```yaml parsed: - address_families: - afi: ipv4 routes: - dest: 198.51.100.0/24 next_hops: - forward_router_address: 198.51.101.3 name: route_3 - distance_metric: 30 forward_router_address: 198.51.101.2 name: route_2 - distance_metric: 110 forward_router_address: 198.51.101.1 multicast: true name: route_1 tag: 40 - afi: ipv6 routes: - dest: 2001:DB8:0:3::/64 next_hops: - forward_router_address: 2001:DB8:0:3::2 name: test_v6 tag: 105 - address_families: - afi: ipv4 routes: - dest: 192.0.2.0/24 next_hops: - forward_router_address: 192.0.2.1 name: test_vrf tag: 50 track: 150 vrf: blue ``` -------------------------------- ### HSRP Configuration Example: GigabitEthernet3 Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_hsrp_interfaces_module.rst This example configures HSRP group 1 on GigabitEthernet3, specifying the virtual IP address and priority, and enabling use-bia. ```text # interface GigabitEthernet3 # standby use-bia # standby 1 ip 172.16.1.1 # standby 1 priority 100 ``` -------------------------------- ### Cisco IOS Route Map Configuration Example Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_route_maps_module.rst This example demonstrates a complex route map configuration with various match and set clauses. It includes matching on security groups, local preference, MPLS labels, IP next-hop, route source, and setting IP precedence, automatic tags, AIGP metrics, and extended communities. ```text route-map test_2 deny 10 match security-group source tag 10 20 match local-preference 55 105 match mpls-label match ipv6 next-hop prefix-list test_new match ipv6 route-source route_src_acl match ipv6 address test_ip_acl set extcommunity cost pre-bestpath 10 100 set ip df 1 set ip next-hop recursive global 198.51.110.1 set ip next-hop verify-availability 198.51.111.1 100 track 10 set ip precedence critical set ip address prefix-list 192.0.2.1 set automatic-tag set aigp-metric 100 ``` ```text route-map test_1 deny 20 continue 100 match track 105 match tag list test_match_tag match ipv6 address test_acl_20 match route-type level-1 match as-path 200 100 match additional-paths advertise-set all group-best ``` ```text route-map test_1 deny 10 description this is test route match security-group source tag 10 20 match ip next-hop prefix-list test_2_new test_1_new match ip route-source 10 match local-preference 100 50 match mpls-label ``` -------------------------------- ### HSRP Configuration Example: GigabitEthernet2 Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_hsrp_interfaces_module.rst This example configures HSRP group 2 on GigabitEthernet2, setting a secondary IP address and using an MD5 authentication key chain. ```text # interface GigabitEthernet2 # standby follow VLAN70_GROUP # standby 2 ip 172.16.2.1 secondary # standby 2 authentication md5 key-chain AUTH_CHAIN ``` -------------------------------- ### Render LLDP Global Configuration Commands Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lldp_global_module.rst This example shows how to render the Ansible module commands for LLDP global configuration. ```APIDOC ## Render LLDP Global Configuration Commands ### Description Renders the commands necessary to configure LLDP global settings based on the provided configuration. ### Method `cisco.ios.ios_lldp_global` ### Parameters #### Request Body - **config** (dict) - Required - A dictionary defining the desired LLDP global configuration. - **holdtime** (int) - The LLDP hold time in seconds. - **enabled** (bool) - Set to true to enable LLDP, false to disable. - **reinit** (int) - The LLDP reinitialization timer in seconds. - **timer** (int) - The LLDP timer in seconds. - **state** (str) - Required - Set to 'rendered' to generate configuration commands. ### Response #### Success Response (200) - **rendered** (list) - A list of commands to be executed on the device. ### Response Example ```json { "rendered": [ "lldp holdtime 10", "lldp run", "lldp timer 10", "lldp reinit 3" ] } ``` ``` -------------------------------- ### Gather LLDP Interface Configurations Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lldp_interfaces_module.rst This example shows how to gather the current LLDP interface configurations from the device. The `config` parameter can be used to specify which interfaces to gather information from, or it can be left empty to gather all. ```yaml - name: Gather listed LLDP interfaces with provided configurations cisco.ios.ios_lldp_interfaces: config: state: gathered ``` -------------------------------- ### Gather LLDP Global Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lldp_global_module.rst This example demonstrates how to gather the current LLDP global configuration from a Cisco IOS device. ```APIDOC ## Gather LLDP Global Configuration ### Description Gathers the current LLDP global configuration from the device. ### Method `cisco.ios.ios_lldp_global` ### Parameters #### Request Body - **state** (str) - Required - Set to 'gathered' to collect current configuration. ### Response #### Success Response (200) - **gathered** (dict) - A dictionary containing the current LLDP global configuration. - **enabled** (bool) - Indicates if LLDP is enabled. - **holdtime** (int) - The LLDP hold time in seconds. - **reinit** (int) - The LLDP reinitialization timer in seconds. - **timer** (int) - The LLDP timer in seconds. ### Response Example ```json { "gathered": { "enabled": true, "holdtime": 10, "reinit": 3, "timer": 10 } } ``` ``` -------------------------------- ### Create VXLAN VTEP Interface Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vxlan_vtep_module.rst Example of configuring a VXLAN VTEP interface with source interface and member VNIs. ```APIDOC ## POST /api/config/cisco.ios/vxlan_vtep ### Description Configures a VXLAN VTEP interface with specified source interface and member VNIs. ### Method POST ### Endpoint /api/config/cisco.ios/vxlan_vtep ### Parameters #### Request Body - **config** (list) - Required - List of VXLAN VTEP configurations. - **interface** (string) - Required - The name of the interface. - **source_interface** (string) - Optional - The source interface for the VTEP. - **member** (dict) - Optional - Configuration for member VNIs. - **vni** (dict) - Required - VNI configuration. - **l2vni** (list) - Optional - List of L2 VNIs. - **vni** (integer) - Required - The VNI ID. - **mcast_group** (list) - Optional - List of multicast groups. - **address** (string) - Required - The multicast group address. - **vni** (integer) - Required - The VNI ID. - **state** (string) - Optional - The desired state of the configuration. Defaults to 'present'. ### Request Example ```json { "config": [ { "interface": "nve1", "source_interface": "Loopback2", "member": { "vni": { "l2vni": [ {"vni": 10101}, {"vni": 10102} ], "mcast_group": [ {"address": "FF0E:225::101", "vni": 10101}, {"address": "225.0.0.101", "vni": 10102} ] } } } ], "state": "present" } ``` ### Response #### Success Response (200) - **changed** (boolean) - Indicates if any changes were made. - **before** (dict) - The configuration before the module execution. - **after** (dict) - The resulting configuration after module execution. #### Response Example ```json { "changed": true, "before": { "interface nve1\n no ip address" }, "after": { "interface nve1\n no ip address\n source-interface Loopback2\n host-reachability protocol bgp\n member vni 10101 mcast-group FF0E:225::101\n member vni 10102 mcast-group 225.0.0.101" } } ``` ``` -------------------------------- ### Using deleted by Name Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_prefix_lists_module.rst This example demonstrates how to delete a prefix list by its name. Ensure the prefix list exists before attempting deletion. ```yaml # Using deleted by Name # Before state: # ------------- # # router-ios#sh running-config | section ^ip prefix-list|^ipv6 prefix-list # ip prefix-list 10 description this is test description ``` -------------------------------- ### Test reachability to ipv6 address Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_ping_module.rst This example demonstrates how to test reachability to an IPv6 address using the ios_ping module. ```APIDOC ## POST /api/v1/ios/ping ### Description Tests network reachability to a specified IPv6 address on a Cisco IOS device. ### Method POST ### Endpoint /api/v1/ios/ping ### Parameters #### Request Body - **dest** (string) - Required - The IPv6 address to ping. - **afi** (string) - Required - Address Family Interface. Set to 'ipv6' for IPv6 ping. ### Request Example ```json { "dest": "2001:db8:ffff:ffff:ffff:ffff:ffff:ffff", "afi": "ipv6" } ``` ### Response #### Success Response (200) - **commands** (list) - A list of commands sent to the device. - **packet_loss** (string) - The percentage of packets lost during the ping test. - **packets_rx** (integer) - The number of packets successfully received. - **packets_tx** (integer) - The number of packets successfully transmitted. - **rtt** (dictionary) - Round Trip Time statistics, including 'avg', 'max', and 'min'. #### Response Example ```json { "commands": ["ping vrf prod 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff count 20 source loopback0"], "packet_loss": "0%", "packets_rx": 20, "packets_tx": 20, "rtt": { "avg": 2, "max": 8, "min": 1 } } ``` ``` -------------------------------- ### Configure set of VRFs and purge any others Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst This example configures a specific set of VRFs and removes any VRFs not listed. Set 'purge' to true to remove extraneous VRFs. ```yaml - name: Configure set of VRFs and purge any others cisco.ios.ios_vrf: vrfs: - red - blue - green purge: true ``` -------------------------------- ### Cisco IOS ACL Configuration Example Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_acls_module.rst Demonstrates overriding remarks and ACE configurations for an extended ACL named 'TEST' using the `ios_acls` module. ```yaml - name: Override remarks and ace configurations cisco.ios.ios_acls: config: - afi: ipv4 acls: - name: TEST acl_type: extended aces: - sequence: 10 ``` -------------------------------- ### Parse VRF Address Family Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_address_family_module.rst This example demonstrates how to use the `ios_vrf_address_family` module to parse an existing VRF address family configuration from a file. ```APIDOC ## POST /api/vrf/address-family ### Description Parses the VRF address family configuration from a given running configuration. ### Method POST ### Endpoint /api/vrf/address-family ### Parameters #### Request Body - **running_config** (string) - Required - The running configuration to parse. - **state** (string) - Optional - The state of the configuration. Defaults to 'parsed'. ### Request Example ```json { "running_config": "{{ lookup('file', 'parsed.cfg') }}", "state": "parsed" } ``` ### Response #### Success Response (200) - **parsed** (list) - A list containing the parsed VRF address family configuration. - **address_families** (list) - **afi** (string) - The address family identifier (e.g., 'ipv4'). - **bgp** (dict) - BGP specific configurations. - **next_hop** (dict) - **loopback** (integer) - The loopback interface number for the next hop. - **export** (dict) - Export configurations. - **ipv4** (dict) - **multicast** (dict) - **map** (string) - The name of the map for IPv4 multicast export. - **prefix** (integer) - The prefix for IPv4 multicast export. - **unicast** (dict) - **allow_evpn** (boolean) - Whether to allow EVPN for IPv4 unicast export. - **map** (string) - The name of the map for IPv4 unicast export. - **prefix** (integer) - The prefix for IPv4 unicast export. - **map** (string) - The name of the map for general export. - **import_config** (dict) - Import configurations. - **ipv4** (dict) - **multicast** (dict) - **map** (string) - The name of the map for IPv4 multicast import. - **prefix** (integer) - The prefix for IPv4 multicast import. - **unicast** (dict) - **allow_evpn** (boolean) - Whether to allow EVPN for IPv4 unicast import. - **limit** (integer) - The limit for IPv4 unicast import. - **map** (string) - The name of the map for IPv4 unicast import. - **map** (string) - The name of the map for general import. - **safi** (string) - The subsequent address family identifier (e.g., 'unicast'). - **name** (string) - The name of the VRF. #### Response Example ```json { "parsed": [ { "address_families": [ { "afi": "ipv4", "bgp": { "next_hop": { "loopback": 40 } }, "export": { "ipv4": { "multicast": { "map": "single", "prefix": 345 }, "unicast": { "allow_evpn": true, "map": "test-map", "prefix": 67 } }, "map": "testing-map" }, "import_config": { "ipv4": { "multicast": { "map": "import-map", "prefix": 89 }, "unicast": { "allow_evpn": true, "limit": 12, "map": "ran-map" } }, "map": "import-map" } } ], "safi": "unicast", "name": "test" } ] } ``` ``` -------------------------------- ### Create VRF with Both IPv6 Import and Export Route Targets Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst Use this example to create a VRF and define its IPv6 import and export route targets. The 'name' and 'rd' parameters are mandatory. ```yaml cisco.ios.ios_vrf: name: test_both_ipv6 rd: 1:100 route_both_ipv6: - 1:100 - 3:100 ``` -------------------------------- ### Create VRF with IPv6 Route Import Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst This example demonstrates creating a VRF and defining its IPv6 route import targets. The 'name' and 'rd' parameters are essential for VRF identification. ```yaml cisco.ios.ios_vrf: name: test_import_ipv6 rd: 1:100 route_import_ipv6: - 1:100 - 3:100 ``` -------------------------------- ### Create VRF with IPv6 Export Route Targets Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vrf_module.rst This example shows how to create a VRF and define its IPv6 export route targets. The 'name' and 'rd' parameters are mandatory. ```yaml cisco.ios.ios_vrf: name: test_export_ipv6 rd: 1:100 route_export_ipv6: - 1:100 - 3:100 ``` -------------------------------- ### Configure Extended ACL with Remarks Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_acls_module.rst This example demonstrates configuring an extended ACL with specific ACEs and associated remarks. It shows how to define source and destination, protocol, and other parameters for network traffic control. ```yaml - acls: - aces: - destination: any: true port_protocol: eq: telnet dscp: af11 grant: deny protocol: tcp protocol_options: tcp: ack: true sequence: 10 source: any: true port_protocol: eq: www name: R1_TRAFFIC afi: ipv6 ``` -------------------------------- ### Use Full-Form Commands for Idempotency with ios_config Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_config_module.rst For idempotency, use full-form commands instead of abbreviations. This example shows the correct way to use 'shutdown' and specifies the full interface name. ```yaml - name: For idempotency, use full-form commands cisco.ios.ios_config: lines: # - shut - shutdown # parents: int gig1/0/11 parents: interface GigabitEthernet1/0/11 ``` -------------------------------- ### Configure Interface with No IP Address and Shutdown Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_interfaces_module.rst This example shows how to configure an interface without an IP address and then shut it down. The 'no_ip_address' parameter removes any existing IP configuration. ```yaml - name: "Configure GigabitEthernet4 without IP and shutdown" cisco.ios.ios_interfaces: config: - name: GigabitEthernet4 no_ip_address: true shutdown: true negotiation: auto state: present ``` -------------------------------- ### Configure HSRP on GigabitEthernet3 and GigabitEthernet4 Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_hsrp_interfaces_module.rst This example demonstrates how to configure HSRP on GigabitEthernet3 and GigabitEthernet4 interfaces. It specifies HSRP group numbers, virtual IP addresses, priorities, and authentication methods. ```yaml - name: GigabitEthernet3 standby_options: - group_no: 1 ip: - virtual_ip: 172.16.1.1 priority: 100 - name: GigabitEthernet4 - delay: minimum: 5555 reload: 556 mac_refresh: 45 name: Vlan70 redirect: advertisement: authentication: key_chain: HSRP_CHAIN timers: adv_timer: 10 holddown_timer: 55 standby_options: - authentication: encryption: 7 key_string: 0123456789ABCDEF follow: MASTER_GROUP group_name: PRIMARY_GROUP group_no: 10 ip: - secondary: true virtual_ip: 10.0.10.2 preempt: delay: true enabled: true minimum: 100 reload: 50 sync: 30 priority: 110 track: - decrement: 20 track_no: 1 - follow: MASTER_GROUP group_name: IPV6_GROUP group_no: 20 ipv6: addresses: - 2001:DB8:20::1/64 autoconfig: true mac_address: 0000.0000.0014 priority: 120 version: 2 - delay: minimum: 100 reload: 200 name: Vlan100 standby_options: - group_name: BACKUP_GROUP group_no: 5 ip: - virtual_ip: 192.168.1.1 preempt: enabled: true priority: 150 track: - decrement: 30 track_no: 10 version: 2 ``` -------------------------------- ### Example SNMP Server Configuration Commands Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_snmp_server_module.rst A list of commands that might be fired by Ansible to configure various SNMP server settings, including traps, hosts, groups, communities, and password policies. ```text snmp-server contact contact updated using merged ``` ```text snmp-server file-transfer access-group test protocol ftp ``` ```text snmp-server enable traps msdp ``` ```text snmp-server enable traps syslog ``` ```text snmp-server enable traps tty ``` ```text snmp-server enable traps ospf cisco-specific errors ``` ```text snmp-server enable traps ospf cisco-specific retransmit ``` ```text snmp-server enable traps ospf cisco-specific lsa ``` ```text snmp-server enable traps ospf cisco-specific state-change nssa-trans-change ``` ```text snmp-server enable traps ospf cisco-specific state-change shamlink interface ``` ```text snmp-server enable traps ospf cisco-specific state-change shamlink neighbor ``` ```text snmp-server enable traps ospf errors ``` ```text snmp-server enable traps ospf retransmit ``` ```text snmp-server enable traps ospf lsa ``` ```text snmp-server enable traps ospf state-change ``` ```text snmp-server enable traps cef resource-failure peer-state-change peer-fib-state-change inconsistency ``` ```text snmp-server host 172.16.2.9 informs version 2c mergedComm msdp stun pki ``` ```text snmp-server host 172.16.2.9 mergedComm slb pki ``` ```text snmp-server group mergedGroup v3 auth ``` ```text snmp-server engineID remote 172.16.0.12 udp-port 25 AB0C5342FF0F ``` ```text snmp-server community mergedComm rw testACL ``` ```text snmp-server password-policy MergedPolicy define max-len 24 upper-case 12 lower-case 12 special-char 32 digits 23 change 3 ``` ```text snmp-server password-policy MergedPolicy2 define min-len 12 upper-case 12 special-char 22 change 43 ``` ```text snmp-server password-policy policy3 define min-len 12 max-len 12 upper-case 12 special-char 22 digits 23 change 11 ``` ```text snmp-server user userPaul dev v1 access 24 ``` -------------------------------- ### Install Cisco IOS Collection via requirements.yml Source: https://github.com/ansible-collections/cisco.ios/blob/main/README.md Include the Cisco IOS collection in a requirements.yml file for installation with Ansible Galaxy. ```yaml --- collections: - name: cisco.ios ``` -------------------------------- ### Parse ACL Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_acls_module.rst This example shows how to use the `ios_acls` module to parse ACL configurations from a file. It reads a configuration file containing ACL definitions and returns a structured representation of the ACLs. ```APIDOC ## POST /api/acl/parse ### Description This endpoint parses Access Control List (ACL) configurations from a provided source, such as a file or string. ### Method POST ### Endpoint /api/acl/parse ### Parameters #### Request Body - **running_config** (string) - Required - The configuration content to parse, typically read from a file. - **state** (string) - Optional - The state of the ACL ('parsed'). Defaults to 'parsed'. ### Request Example ```json { "running_config": "IPv6 access-list R1_TRAFFIC\ndeny tcp any eq www any eq telnet ack dscp af11", "state": "parsed" } ``` ### Response #### Success Response (200) - **parsed** (dict) - A structured representation of the parsed ACLs. - **acls** (list) - A list of ACL objects. - **name** (string) - The name of the ACL. - **afi** (string) - Address Family Identifier (e.g., 'ipv6'). - **aces** (list) - A list of Access Control Entries (ACEs). - **sequence** (integer) - The sequence number of the ACE. - **grant** (string) - The action (e.g., 'deny', 'permit'). - **protocol** (string) - The protocol (e.g., 'tcp'). - **source** (dict) - Source details. - **any** (boolean) - True if source is 'any'. - **port_protocol** (dict) - Source port and protocol. - **eq** (string) - Equal to a specific port (e.g., 'www'). - **destination** (dict) - Destination details. - **any** (boolean) - True if destination is 'any'. - **port_protocol** (dict) - Destination port and protocol. - **eq** (string) - Equal to a specific port (e.g., 'telnet'). - **protocol_options** (dict) - Protocol-specific options. - **tcp** (dict) - TCP specific options. - **ack** (boolean) - Indicates if the ACK flag is set. - **dscp** (string) - Differentiated Services Code Point value. #### Response Example ```json { "parsed": { "acls": [ { "name": "R1_TRAFFIC", "afi": "ipv6", "aces": [ { "sequence": 10, "grant": "deny", "protocol": "tcp", "source": { "any": true, "port_protocol": { "eq": "www" } }, "destination": { "any": true, "port_protocol": { "eq": "telnet" } }, "protocol_options": { "tcp": { "ack": true } }, "dscp": "af11" } ] } ] } } ``` ``` -------------------------------- ### Install Cisco IOS Collection via CLI Source: https://github.com/ansible-collections/cisco.ios/blob/main/README.md Install the Cisco IOS collection directly using the Ansible Galaxy command-line interface. ```bash ansible-galaxy collection install cisco.ios ``` -------------------------------- ### Sample Commands Executed Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lacp_module.rst This sample shows the set of commands that were pushed to the remote device. ```text ['lacp system-priority 10'] ``` -------------------------------- ### Handle Prompts with Commands Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_command_module.rst This example demonstrates how to run commands that require user confirmation by specifying the `prompt` and `answer` for each command. Use `\r` for a newline or Enter key press when no specific input is needed. ```yaml - name: Run commands that require answering a prompt cisco.ios.ios_command: commands: - command: "clear counters GigabitEthernet2" prompt: 'Clear "show interface" counters on this interface [confirm]' answer: "y" - command: "clear counters GigabitEthernet3" prompt: "[confirm]" answer: "\r" ``` -------------------------------- ### Example Parsed Configuration File Content Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_static_routes_module.rst This is the content of a `parsed.cfg` file, representing static routes in a format that can be read by the `ios_static_routes` module when `state: parsed` is used. It includes both IPv4 and IPv6 routes. ```text ip route vrf blue 192.0.2.0 255.255.255.0 192.0.2.1 tag 50 name test_vrf track 150 ip route 198.51.100.0 255.255.255.0 198.51.101.3 name route_3 ip route 198.51.100.0 255.255.255.0 198.51.101.2 30 name route_2 ip route 198.51.100.0 255.255.255.0 198.51.101.1 110 tag 40 name route_1 multicast ipv6 route 2001:DB8:0:3::/64 2001:DB8:0:3::2 tag 105 name test_v6 ``` -------------------------------- ### Create New User with Hashed Password Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_user_module.rst This example demonstrates how to create a new user account with a securely hashed password. The 'type' parameter specifies the hashing algorithm, and the 'value' should be replaced with the actual hashed password. ```yaml - name: Create a new user with hashed password cisco.ios.ios_user: name: ansibletest5 hashed_password: type: 9 value: "thiswillbereplacedwithhashedpassword" state: present ``` -------------------------------- ### Check Startup Configuration Against Running Configuration with ios_config Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_config_module.rst Compare the startup configuration against the running configuration. 'diff_against: startup' specifies this comparison. 'diff_ignore_lines' can be used to ignore specific lines during the diff. ```yaml - name: Check the startup-config against the running-config cisco.ios.ios_config: diff_against: startup diff_ignore_lines: - ntp clock .* ``` -------------------------------- ### Route-Map Configuration with Description and IP Next-Hop Prefix-List Match Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_route_maps_module.rst This example shows a route-map entry with a description and a match for IP next-hop prefix-list. It's used for applying policies based on next-hop reachability. ```text route-map test_1 deny 10 description this is test route match ip next-hop prefix-list test_2_new test_1_new ``` -------------------------------- ### Cisco IOS Module Example: Merged State Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_hsrp_interfaces_module.rst This example demonstrates using the Cisco IOS module with the 'merged' state. It shows the configuration before applying the state, specifically for an interface section. ```yaml # Using merged # Before state: # - - - - - - - - - - - - - - - # # Router#show running-config | section ^interface # interface GigabitEthernet1 # description Management interface do not change # ip address dhcp ``` -------------------------------- ### EVPN Ethernet Segment Configuration Example Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_evpn_ethernet_module.rst This example shows the configuration of an EVPN Ethernet Segment with specific identifier, redundancy, and DF-election settings. It is used to manage L2VPN EVPN configurations on Cisco IOS devices. ```text l2vpn evpn ethernet-segment 1 identifier type 0 00.00.00.00.00.00.00.00.01 redundancy single-active ! l2vpn evpn ethernet-segment 2 identifier type 0 00.00.00.00.00.00.00.00.02 redundancy single-active df-election preempt-time 1 ! l2vpn evpn ethernet-segment 3 identifier type 3 system-mac 00.00.00.00.00.00.00.00.03 redundancy single-active ! l2vpn evpn ethernet-segment 4 identifier type 0 00.00.00.00.00.00.00.00.04 redundancy all-active df-election wait-time 1 ! ``` -------------------------------- ### Sample return value for commands Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_ping_module.rst This sample shows the command that was sent to the device. It is always returned. ```string ['ping vrf prod 198.51.100.251 count 20 source loopback0'] ``` -------------------------------- ### Sample Rendered Configuration Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_lag_interfaces_module.rst This sample shows the rendered configuration for interface GigabitEthernet0/2, including channel-group settings. This output is in device-native format. ```text [ 'interface GigabitEthernet0/2', 'channel-group 20 mode auto', 'channel-group 20 mode active link 60' ] ``` -------------------------------- ### Delete VXLAN VTEP Interface Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vxlan_vtep_module.rst Example of deleting a VXLAN VTEP interface. ```APIDOC ## DELETE /api/config/cisco.ios/vxlan_vtep ### Description Deletes a VXLAN VTEP interface configuration. ### Method DELETE ### Endpoint /api/config/cisco.ios/vxlan_vtep ### Parameters #### Request Body - **config** (list) - Required - List of VXLAN VTEP configurations to delete. - **interface** (string) - Required - The name of the interface to delete. - **state** (string) - Required - Must be set to 'deleted'. ### Request Example ```json { "config": [ { "interface": "nve1" } ], "state": "deleted" } ``` ### Response #### Success Response (200) - **changed** (boolean) - Indicates if any changes were made. - **before** (dict) - The configuration before the module execution. - **after** (dict) - The resulting configuration after module execution. #### Response Example ```json { "changed": true, "before": { "interface nve1\n no ip address\n source-interface Loopback2\n host-reachability protocol bgp\n member vni 10101 mcast-group FF0E:225::101\n member vni 10201 mcast-group FF0E:225::102" }, "after": { "interface nve1\n no ip address" } } ``` ``` -------------------------------- ### Parse OSPF Configurations from File Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_ospf_interfaces_module.rst This example demonstrates parsing OSPF configurations from a file. The 'parsed.cfg' file should contain interface configurations in Cisco IOS format. This functionality is useful for importing existing configurations into Ansible. ```text interface GigabitEthernet0/2 interface GigabitEthernet0/1 ip ospf network broadcast ip ospf resync-timeout 10 ip ospf dead-interval 5 ip ospf priority 25 ip ospf demand-circuit ignore ip ospf bfd ip ospf adjacency stagger disable ``` -------------------------------- ### Route-Map Configuration with AS-Path and IPv6 Address Match Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_route_maps_module.rst This example shows matching AS-path and IPv6 addresses within a route-map. It's useful for filtering routes based on AS path information and IPv6 prefixes. ```text match as-path 200 100 match ipv6 address test_acl_20 ``` -------------------------------- ### Delete VXLAN VTEP Interface with No Config Source: https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_vxlan_vtep_module.rst Example of deleting all configurations for a VXLAN VTEP interface. ```APIDOC ## DELETE /api/config/cisco.ios/vxlan_vtep ### Description Deletes all configurations for a VXLAN VTEP interface. ### Method DELETE ### Endpoint /api/config/cisco.ios/vxlan_vtep ### Parameters #### Request Body - **state** (string) - Required - Must be set to 'deleted'. ### Request Example ```json { "state": "deleted" } ``` ### Response #### Success Response (200) - **changed** (boolean) - Indicates if any changes were made. - **before** (dict) - The configuration before the module execution. - **after** (dict) - The resulting configuration after module execution. #### Response Example ```json { "changed": true, "before": { "interface nve1\n no ip address\n source-interface Loopback2\n host-reachability protocol bgp\n member vni 10101 mcast-group FF0E:225::101\n member vni 10201 mcast-group FF0E:225::102" }, "after": { "interface nve1\n no ip address" } } ``` ```