Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace not working anymore with at least interfaces & l2_interfaces and Subinterfaces #525

Open
weippertt opened this issue Dec 2, 2024 · 2 comments
Assignees

Comments

@weippertt
Copy link

SUMMARY

Replace action with new Subinterfaces (dot1q) doesn't work anymore with 10.1.0/10.2.2 and IOS XR Version 24.2.2/24.2.2 LNT

ISSUE TYPE
  • Bug Report
COMPONENT NAME

interfaces
l2_interfaces

ANSIBLE VERSION
ansible [core 2.15.0]
  config file = /home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg
  configured module search path = ['/home/weipperttadm/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/weipperttadm/pyenv/lib/python3.9/site-packages/ansible
  ansible collection location = /home/weipperttadm/ansible-aap/collections:/home/weipperttadm/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/weipperttadm/pyenv/bin/ansible
  python version = 3.9.2 (default, Dec  1 2024, 12:12:57) [GCC 10.2.1 20210110] (/home/weipperttadm/pyenv/bin/python)
  jinja version = 3.1.2
  libyaml = True
COLLECTION VERSION

# /home/weipperttadm/.ansible/collections/ansible_collections
Collection  Version
----------- -------
cisco.iosxr 10.2.2

CONFIGURATION
CONFIG_FILE() = /home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg
DEFAULT_ROLES_PATH(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = ['/home/weipperttadm/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles', '/home/weipperttadm/Develop/COLO-IA/Ansible/roles']
DEPRECATION_WARNINGS(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = False
HOST_KEY_CHECKING(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = False
INTERPRETER_PYTHON(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = /usr/bin/python3
PERSISTENT_COMMAND_TIMEOUT(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = 300
PERSISTENT_CONNECT_RETRY_TIMEOUT(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = 300
PERSISTENT_CONNECT_TIMEOUT(/home/weipperttadm/Develop/COLO-IA/Ansible/ansible.cfg) = 300

OS / ENVIRONMENT

IOS XR Versoin Tested: 24.2.2 (on ASR9K) and 24.2.2 LNT (on NCS 540)

STEPS TO REPRODUCE
  # Configure Interface Physics
  - name: Basic Interface Configuration (Physics)
    cisco.iosxr.iosxr_interfaces:
      config: "{{ lookup('template', 'templates/interfaces_iosxr.j2') | from_yaml  }}"
      state: replaced

  # Configure Interface L2 settings
  - name: Basic Interface Configuration (L2
    cisco.iosxr.iosxr_l2_interfaces:
      config: "{{ lookup('template', 'templates/interfaces_l2_iosxr.j2') | from_yaml }}"
      state: replaced
#### Interfaces J2:
{% for interface in interfaces %}
{% if not interface.mgmt_only %}
- name: {{ interface.name }}
  description: {{ (interface.description == "") |ternary("Configured by Ansible/Netbox", interface.description ) }}
  enabled: {{ interface.enabled|lower }}
  mtu: {{ interface.mtu|default(1500) }}
{% endif %}
{% endfor %}
#### Interfaces L2 J2:
{% for interface in interfaces %}
{% if not interface.mgmt_only %}
- name: {{ interface.name }}
{% if interface.tagged_vlans[0] is defined %}
  encapsulation:
    dot1q: {{ interface.tagged_vlans[0].vid }}
{% endif %}
{% endif %}
{% endfor %}
EXPECTED RESULTS

Changed and Replaced Configuration to add interface GigabitEthernet0/0/0/17.999 , enable it
and add encapsulation dot1q.

ACTUAL RESULTS
    "before": [
        {
            "description": "Configured by Ansible/Netbox",
            "enabled": false,
            "name": "GigabitEthernet0/0/0/0"
        },
	[ … ]
        {
            "description": "Configured by Ansible/Netbox",
            "enabled": false,
            "name": "GigabitEthernet0/0/0/17"
        },
	[ … ]
    ],
    "changed": false,
    "commands": [],
    "invocation": {
        "module_args": {
            "config": [
                {
                    "description": "Configured by Ansible/Netbox",
                    "duplex": null,
                    "enabled": false,
                    "mtu": null,
                    "name": "GigabitEthernet0/0/0/0",
                    "speed": null
                },
		[ … ]
                {
                    "description": "Configured by Ansible/Netbox",
                    "duplex": null,
                    "enabled": false,
                    "mtu": null,
                    "name": "GigabitEthernet0/0/0/17",
                    "speed": null
                },
                {
                    "description": "Configured by Ansible/Netbox",
                    "duplex": null,
                    "enabled": true,
                    "mtu": null,
                    "name": "GigabitEthernet0/0/0/17.999",
                    "speed": null
                },
		[ … ]
            ],
            "running_config": null,
            "state": "replaced"
        }
    }
             
@weippertt
Copy link
Author

I can maybe narrow it down to the following, in l2_interfaces there is an version check if os_version is set and < "7.0.0", it seems this check doesn't work correctly in Version 24.2.2 (i assume all 24.x.x) and therefore it uses the wrong dot1q config block.

I found the issue in facts and config l2_interfaces.py ... but i'm currently not clear how the Version check is performed.

@weippertt
Copy link
Author

weippertt commented Feb 14, 2025

If i change the os_version check to exact version check, it works fine, but this may only work with 24.2.2:

facts:
if os_version and (Version(os_version) > Version("7.0.0") or Version(os_version) == Version("24.2.2")):
config:
if os_version and ( Version(os_version) < Version("7.0.0") and Version(os_version) != Version("24.2.2")):

It is a bit irritating, why the version check is in facts checked with > and in config with < to do the correct dot1q commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants