ansible-collections / cisco.ios

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

ios_facs: Cannot collect vlans #1008

Closed akira6592 closed 4 months ago

akira6592 commented 4 months ago
SUMMARY

Cannot collect vlans network resource facts with the ios_facts module.

ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
% ansible --version
ansible [core 2.16.0]
COLLECTION VERSION
 % ansible-galaxy collection list cisco.ios

# /Users/akira/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios  6.0.0  

The version 5.3.0 has the same issue.

CONFIGURATION
CONFIG_FILE() = /Users/akira/ansible/qa/ansible.cfg
HOST_KEY_CHECKING(/Users/akira/ansible/qa/ansible.cfg>
OS / ENVIRONMENT
STEPS TO REPRODUCE
---
- name: Test play
  hosts: sw01
  gather_facts: false

  tasks:
    - name: ios_facts
      cisco.ios.ios_facts:
        gather_network_resources:
          - vlans

    - name: debug facts
      debug:
        var: ansible_facts.network_resources
EXPECTED RESULTS
% ansible-playbook -i inventory.ini ios_l2.yml

PLAY [Test play] **************************************************************************************************

TASK [ios_facts] **************************************************************************************************
ok: [sw01]

TASK [debug facts] ************************************************************************************************
ok: [sw01] => {
    "ansible_facts.network_resources": {
        "vlans": [
            {
                "mtu": 1500,
                "name": "default",
                "shutdown": "disabled",
                "state": "active",
                "vlan_id": 1
            },
            {
                "mtu": 1500,
                "name": "VLAN0002",
                "shutdown": "disabled",
                "state": "active",
                "vlan_id": 2
            },
            {
                "mtu": 1500,
                "name": "VLAN0003",
                "shutdown": "disabled",
                "state": "active",
                "vlan_id": 3
            },
            {
                "mtu": 1500,
                "name": "VLAN0004",
                "shutdown": "disabled",
                "state": "active",
                "vlan_id": 4
            },
            {
                "mtu": 1500,
                "name": "VLAN0005",
                "shutdown": "disabled",
                "state": "active",
                "vlan_id": 5
            },
            {
                "mtu": 1500,
                "name": "fddi-default",
                "shutdown": "enabled",
                "state": "active",
                "vlan_id": 1002
            },
            {
                "mtu": 1500,
                "name": "token-ring-default",
                "shutdown": "enabled",
                "state": "active",
                "vlan_id": 1003
            },
            {
                "mtu": 1500,
                "name": "fddinet-default",
                "shutdown": "enabled",
                "state": "active",
                "vlan_id": 1004
            },
            {
                "mtu": 1500,
                "name": "trnet-default",
                "shutdown": "enabled",
                "state": "active",
                "vlan_id": 1005
            }
        ]
    }
}

PLAY RECAP ********************************************************************************************************
sw01                       : ok=2    changed=0    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0 
ACTUAL RESULTS

The playbook makes an error.

% ansible-playbook -i inventory.ini ios_l2.yml

PLAY [Test play] ***************************************************************

TASK [ios_facts] ***************************************************************
fatal: [sw01]: FAILED! => {
    "changed": false,
    "msg": "'configuration'"
}

PLAY RECAP *********************************************************************
sw01                       : ok=0    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
ADDITIONAL INFORMATION

The result of show vlan command as follows:

sw01#show vlan

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/0, Gi0/2, Gi0/3
2    VLAN0002                         active    
3    VLAN0003                         active    
4    VLAN0004                         active    
5    VLAN0005                         active    
1002 fddi-default                     act/unsup 
1003 token-ring-default               act/unsup 
1004 fddinet-default                  act/unsup 
1005 trnet-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0   
2    enet  100002     1500  -      -      -        -    -        0      0   
3    enet  100003     1500  -      -      -        -    -        0      0   
4    enet  100004     1500  -      -      -        -    -        0      0   
5    enet  100005     1500  -      -      -        -    -        0      0   
1002 fddi  101002     1500  -      -      -        -    -        0      0   

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1003 tr    101003     1500  -      -      -        -    -        0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trnet 101005     1500  -      -      -        ibm  -        0      0   

Remote SPAN VLANs
------------------------------------------------------------------------------

Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------
akira6592 commented 4 months ago

Perhaps this will be fixed when #1005 is merged.

I posted this issue for those who will search and find this issue later.

roverflow commented 4 months ago

@akira6592 , I will be closing this issue as its a duplicate of #999, Thanks for reporting

akira6592 commented 4 months ago

I did not notice the duplication. Thank you.