ansible-collections / cisco.ios

Ansible Network Collection for Cisco IOS
GNU General Public License v3.0
261 stars 162 forks source link

What are the argument specifications for the cisco.ios.ios_vrf module and the address-family parameter #1027

Closed dwebr closed 3 months ago

dwebr commented 3 months ago
SUMMARY

It's unclear what the list of dicts that are passed to the address-family parament in the cisco.ios.ios_vrf module should be. The documentation simply states "The list of address families with MDT parameters to be configured on the remote IOS device.".

I've tried passing parameters like the following


# group_vars/ variable file for a particular group
pair_vrfs:
  - name: aci
    description: aci_test_vrf
    state: present
    address_family:
      - afi: ipv4 unicast
        safi: unicast
    interfaces:
      - GigabitEthernet1/0/1
      - 
# Then reference that variable  structure in a playbook using cisco.ios.ios_vrf

- name: "PLAY 1 - MiniDC Build Lab"
  hosts: nxos ios
  gather_facts: false
  connection: network_cli

  tasks:      
    - name: Add Data Plane VRFs
      cisco.ios.ios_vrf:
        vrfs: "{{ pair_vrfs | default([]) + device_vrfs | default([])}}"
      when: ansible_network_os == 'ios' and (pair_vrfs is defined or device_vrfs is defined)
      tags: ['vrfs','vrf']      

But that results in a fatal error when run ...

PLAY [PLAY 1 - MiniDC Build Lab] ************************************************************************************************************************************************************************************************************

TASK [Add Data Plane VRFs] ******************************************************************************************************************************************************************************************************************
fatal: [SIM-DR0x]: FAILED! => {"changed": false, "module_stderr": "'mdt'", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}

I suspect I just don't have the arguments for the address_family parameter defined correctly since it is not defined anywhere that I could find and also not provided as an example in the documentation.

ISSUE TYPE
COMPONENT NAME

https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_vrf_module.html#parameter-address_family

ANSIBLE VERSION
ansible [core 2.14.0]
  config file = /opt/netadmin/ansible/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/netadmin/ve/ansible7/lib/python3.9/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/netadmin/ve/ansible7/bin/ansible
  python version = 3.9.15 (main, Oct 22 2022, 11:54:42) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/opt/netadmin/ve/ansible7/bin/python)
  jinja version = 3.1.2
  libyaml = True

# /opt/netadmin/ve/ansible7/lib/python3.9/site-packages/ansible_collections
Collection Version
---------- -------
cisco.ios  4.0.0

# /home/user/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  6.0.0
roverflow commented 3 months ago

@dwebr The list of dicts would look something like this

- afi: ipv4
  mdt:
      overlay:
          use_bgp:
              enable: true
              spt_only: true
      auto_discovery:
          vxlan:
              enable: true
              inter_as: true
      default:
          vxlan_mcast_group: 239.1.1.1
      data:
          vxlan_mcast_group: 225.2.2.0 0.0.0.255
          threshold: "112"
dwebr commented 3 months ago

@dwebr The list of dicts would look something like this

- afi: ipv4
  mdt:
      overlay:
          use_bgp:
              enable: true
              spt_only: true
      auto_discovery:
          vxlan:
              enable: true
              inter_as: true
      default:
          vxlan_mcast_group: 239.1.1.1
      data:
          vxlan_mcast_group: 225.2.2.0 0.0.0.255
          threshold: "112"

@roverflow - Thanks for the response. I guess I'm still left with some questions though as the mdt structure does not appear to be what I need. Below is an example of a VRF definition for address-family ipv4 that will allow me to create a default route within that vrf. Without the inclusion of address-family under the vrf definition, no layer 3 config can be associated with the vrf.

vrf definition aci
 description aci_test_vrf
 !
 address-family ipv4
 exit-address-family
!
ip route vrf aci 0.0.0.0 0.0.0.0 10.80.140.1
end

Is this something I should open a feature request on?

Dan

Sikhi commented 2 weeks ago

actually it's only answer for a half question.

  1. cisco don't need any of these parameters, as said @dwebr. I have same config and it's works well
    vrf definition my-vrf
    rd 133937:0
    !
    address-family ipv4
    exit-address-family

but this confige not

  cisco.ios.ios_vrf:
    name: service
    description: Services in K8s
    address_family:
      - afi: ipv4
    rd: "133937:1"
fatal: [core]: FAILED! => {
    "changed": false,
    "module_stderr": "'NoneType' object has no attribute 'pop'",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
  1. documentation updated, but there no info that some items a mandatory

looks like much easy just use config