ansible-collections / cisco.ios

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

cisco.ios.ios_vrf rises error when add address-family parameter #1110

Open Pr1meSuspec7 opened 2 months ago

Pr1meSuspec7 commented 2 months ago
SUMMARY

The cisco.ios.ios_vrf module rises an error when add "address-family" parameter:

FAILED! => {"changed": false, "module_stderr": "'NoneType' object has no attribute 'pop'", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}
ISSUE TYPE
COMPONENT NAME

cisco.ios.ios_vrf

ANSIBLE VERSION
ansible [core 2.16.7]
  config file = /home/marcopalmieri/code/github/workshop-ansible/ansible.cfg
  configured module search path = ['/home/marcopalmieri/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/marcopalmieri/code/github/workshop-ansible/venv-workshop-ansible/lib/python3.11/site-packages/ansible
  ansible collection location = /home/marcopalmieri/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/marcopalmieri/code/github/workshop-ansible/venv-workshop-ansible/bin/ansible
  python version = 3.11.9 (main, Apr  6 2024, 17:59:24) [GCC 11.4.0] (/home/marcopalmieri/code/github/workshop-ansible/venv-workshop-ansible/bin/python3.11)
  jinja version = 3.1.4
  libyaml = True
COLLECTION VERSION

-->

# /home/marcopalmieri/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  9.0.1  
CONFIGURATION
CONFIG_FILE() = /home/marcopalmieri/code/github/workshop-ansible/ansible.cfg
DEFAULT_GATHERING(/home/marcopalmieri/code/github/workshop-ansible/ansible.cfg) = explicit
DEFAULT_HOST_LIST(/home/marcopalmieri/code/github/workshop-ansible/ansible.cfg) = ['/home/marcopalmieri/code/github/workshop-ansible/inv.ini']
HOST_KEY_CHECKING(/home/marcopalmieri/code/github/workshop-ansible/ansible.cfg) = False
RETRY_FILES_ENABLED(/home/marcopalmieri/code/github/workshop-ansible/ansible.cfg) = False
OS / ENVIRONMENT

target OS:

Cisco IOS Software, IOSv Software (VIOS-ADVENTERPRISEK9-M), Version 15.6(1)T
STEPS TO REPRODUCE
    - name: Configure a vrf
      cisco.ios.ios_vrf:
        name: RED
        address_family:
          - afi: ipv4
EXPECTED RESULTS
vrf definition RED
 !
 address-family ipv4
 exit-address-family
!
ACTUAL RESULTS
TASK [Configure a vrf] *****************************************************************************************************************************************************************************************************
fatal: [DC1-R1]: FAILED! => {"changed": false, "module_stderr": "'NoneType' object has no attribute 'pop'", "module_stdout": "", "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"}
roverflow commented 2 months ago

@Pr1meSuspec7,

Thank you for reaching out. Unfortunately, we do not support Version 15.6(1)T of the device. Our supported versions include 17.x and above. Could you please check if the issue persists with a 17.x version and let us know? We’d be happy to assist further based on that.

Pr1meSuspec7 commented 2 months ago

Hi @roverflow, thanks for your reply. I just tested on CSR1000v with version software 17.3 and the error persists, but I found the problem:

The issue is in this section of module cisco.ios.ios_vrf:

for want_mdt in want["address_family"]:
    afi = want_mdt["afi"]
    af_dict = {}
    data_dict = want_mdt["mdt"].pop("data", {})        # <-- this is the guilty

This section tries to make a "pop" of "data" key in the "mtd" dictonary and if you don't define the "mtd" and "data" dictonary in the ansible task you get the error mentioned in this issue.

I solved the task execution by defining “mtd” and “date” in the playbook task:

    - name: Configure a vrf named management
      cisco.ios.ios_vrf:
        name: RED
        description: RED VRF
        address_family:
          - afi: ipv4
            mdt:    # <-- insert mdt without value
              data:   # <-- insert data without value
        interfaces:
          - GigabitEthernet4

In this case the playbook works:

PLAY [CONFIGURING VRF] *************************************************************************************************************************************************************************************************

TASK [Configure a vrf named management] ********************************************************************************************************************************************************************************
changed: [CSR1]

PLAY RECAP *************************************************************************************************************************************************************************************************************
CSR1                       : ok=1    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0  

But we don't have the expected result:

CSR1000v#show run vrf RED
Building configuration...

Current configuration : 169 bytes
vrf definition RED
 description RED VRF
!
!                           <- address-family missing
!
interface GigabitEthernet4
 vrf forwarding RED
 no ip address
 shutdown
 negotiation auto
 no mop enabled
 no mop sysid
end

Thanks a lot Marco

wanzel commented 2 months ago

yes, I have the same problem

  tasks:
    - name: Configure VRF
      cisco.ios.ios_vrf:
        address_family:
          - afi: ipv4
        name: CUST-A
        description: VRF CUST-A
        rd: 1:100

        state: present

This task produce this error

fatal: [device.com]: FAILED! => {
    "changed": false,
    "module_stderr": "'NoneType' object has no attribute 'pop'",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
}

The right configuration should be:

vrf definition CUST-A
 description VRF CUST-A
 rd 1:100
 !
 address-family ipv4
 exit-address-family


Ansible version

(venv) ➜  ansible --version
ansible [core 2.17.3]

(venv) ➜  ansible  ansible-galaxy collection list | grep ios
cisco.ios                                9.0.1  

Device software

Cat8000V#sh ver
Cisco IOS XE Software, Version 17.12.02
Cisco IOS Software [Dublin], Virtual XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 17.12.2, RELEASE SOFTWARE (fc2)
wanzel commented 2 months ago

I can see what is a difference. NX-OS has module which deals with address-families