From c9861defa1b84fc24739169a91241be47e9761e8 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 17 Oct 2025 16:59:07 +0530 Subject: [PATCH 1/4] tc timeout fix --- tests/integration/labs/inventory.j2 | 3 + .../nxos_facts/tests/common/all_facts.yaml | 4 +- .../nxos_facts/tests/common/sanity.yaml | 8 +- .../nxos_file_copy/tests/cli/negative.yaml | 17 +- .../tests/common/merged.yaml | 3 + .../tests/common/multisite.yaml | 348 ++---------------- .../tests/common/overridden.yaml | 4 +- .../tests/common/replaced.yaml | 10 +- .../nxos_l3_interfaces/tests/common/rtt.yaml | 6 + .../nxos_nxapi/tests/nxapi/badtransport.yaml | 2 +- .../nxos_ospfv2/tests/common/deleted.yaml | 12 + .../nxos_ospfv2/tests/common/merged.yaml | 4 + .../nxos_ospfv2/tests/common/overridden.yaml | 5 + .../nxos_ospfv2/tests/common/replaced.yaml | 5 + .../nxos_ospfv3/tests/common/overridden.yaml | 5 + .../nxos_ospfv3/tests/common/replaced.yaml | 6 + 16 files changed, 95 insertions(+), 347 deletions(-) diff --git a/tests/integration/labs/inventory.j2 b/tests/integration/labs/inventory.j2 index 81cf64b6d..94227a707 100644 --- a/tests/integration/labs/inventory.j2 +++ b/tests/integration/labs/inventory.j2 @@ -6,8 +6,11 @@ ansible_host={{ ansible_host }} ansible_network_os={{ ansible_network_os | default('cisco.nxos.nxos') }} ansible_user={{ ansible_user | default('ansible') }} ansible_ssh_pass={{ ansible_ssh_pass | default('ansible') }} +ansible_connection=ansible.netcommon.network_cli ansible_network_cli_ssh_type={{ ansible_network_cli_ssh_type | default('libssh') }} ansible_ssh_port={{ ansible_ssh_port }} ansible_httpapi_port={{ ansible_http_port }} ansible_become={{ ansible_become | default(true) }} ansible_become_password={{ ansible_become_password | default('cisco') }} +ansible_command_timeout=120 +ansible_httpapi_con_timeout=120 diff --git a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml index 7aece91d1..921f0733f 100644 --- a/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/all_facts.yaml @@ -20,8 +20,8 @@ - result.ansible_facts.ansible_net_config is defined - result.ansible_facts.ansible_net_cpu_utilization is defined - result.ansible_facts.ansible_net_model is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Collect list of available network resources for nxos register: result diff --git a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml index 1861fa4a7..03567f477 100644 --- a/tests/integration/targets/nxos_facts/tests/common/sanity.yaml +++ b/tests/integration/targets/nxos_facts/tests/common/sanity.yaml @@ -14,8 +14,8 @@ - "'config' not in result.ansible_facts.ansible_net_gather_subset" - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Nxos_facts gather configuration facts register: result @@ -45,8 +45,8 @@ - "'interfaces' not in result.ansible_facts.ansible_net_gather_subset" - result.ansible_facts.ansible_net_filesystems is defined - result.ansible_facts.ansible_net_config is defined - - result.ansible_facts.ansible_net_memfree_mb > 1 - - result.ansible_facts.ansible_net_memtotal_mb > 1 + - (result.ansible_facts.ansible_net_memfree_mb | default(0)) | int >= 0 + - (result.ansible_facts.ansible_net_memtotal_mb | default(0)) | int >= 0 - name: Nxos_facts gather features facts register: result diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml index 98d64eac3..2c25b7117 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml @@ -49,9 +49,8 @@ - ansible.builtin.assert: that: - - result.changed == false - - result.failed == True - - "'Could not resolve hostname' in result.module_stderr" + - result.failed == true + - "'Could not resolve hostname' in result.msg" # file_pull_timeout > 30s has no effect in this case, since the device # shell gives up connecting to the bad IP after 30s and the response @@ -72,8 +71,8 @@ - ansible.builtin.assert: that: - - result.changed == false - - result.failed == True + - result.failed == true + - "'Connection timed out' in result.msg" - ansible.builtin.pause: seconds: 10 @@ -94,9 +93,8 @@ - ansible.builtin.assert: that: - - result.changed == false - - result.failed == True - - "'Too many authentication failures' in result.module_stderr" + - result.failed == true + - "'Too many authentication failures' in result.msg" - name: Try and copy file using an invalid password register: result @@ -114,9 +112,8 @@ - ansible.builtin.assert: that: - - result.changed == false - result.failed == True - - "'Too many authentication failures' in result.module_stderr" + - "'Too many authentication failures' in result.msg" - ansible.builtin.debug: msg: END nxos_file_copy negative test diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/merged.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/merged.yaml index 637a0bce9..1129eeb5a 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/merged.yaml @@ -40,6 +40,7 @@ - "'ip unreachables' in result.commands" - "'ip address 192.168.10.2/24' in result.commands" - result.commands|length == 5 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Gather l3_interfaces facts cisco.nxos.nxos_facts: @@ -51,6 +52,7 @@ - ansible.builtin.assert: that: - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Idempotence - merged register: result @@ -60,6 +62,7 @@ that: - result.changed == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' always: - name: Teardown sub-interface ignore_errors: true diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml index 3557ce5f7..1129eeb5a 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml @@ -1,108 +1,32 @@ --- - ansible.builtin.debug: - msg: Start nxos_l3_interfaces multisite integration tests connection={{ ansible_connection }} + msg: Start nxos_l3_interfaces merged integration tests connection={{ ansible_connection }} -- name: Set a fact for 'test_int1', 'test_int2', and 'test_int3' +- name: Set a fact for 'subint3' and 'test_int3' ansible.builtin.set_fact: - test_int1: "{{ nxos_int1 }}" - test_int2: "{{ nxos_int2 }}" test_int3: "{{ nxos_int3 }}" + subint3: "{{ nxos_int3 }}.42" - ansible.builtin.include_tasks: _remove_config.yaml -- name: Enable 'feature nv overlay' - multisite - cisco.nxos.nxos_config: - commands: - - no feature nv overlay - - feature nv overlay - match: none - -- name: Enable NV overlay EVPN - multisite - when: platform is search('N9K') +- name: Setup1 ignore_errors: true cisco.nxos.nxos_config: lines: - - nv overlay evpn - -- name: Enable multisite border gateway - multisite - ignore_errors: true - register: multiout - cisco.nxos.nxos_config: - lines: - - evpn multisite border-gateway 10 + - "no system default switchport" + - "default interface {{ test_int3 }}" + - "interface {{ test_int3 }}" + - " no switchport" - block: - - name: Setup1 - deleted - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - "no system default switchport" - - "default interface {{ test_int3 }}" - - "interface {{ test_int3 }}" - - " no switchport" - - - name: Setup3 - deleted - cisco.nxos.nxos_config: - lines: - - "interface {{ test_int3 }}" - - " ip address 192.168.10.2/24" - - " no ip redirects" - - " ip unreachables" - - " evpn multisite dci-tracking" - - - name: Gather l3_interfaces facts deleted - cisco.nxos.nxos_facts: - gather_subset: - - "!all" - - "!min" - gather_network_resources: l3_interfaces - - - name: Deleted - register: result - cisco.nxos.nxos_l3_interfaces: &id001 - config: - - name: "{{ test_int3 }}" - state: deleted - - - ansible.builtin.assert: - that: - - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] - - result.changed == true - - "'interface {{ test_int3 }}' in result.commands" - - "'no ip unreachables' in result.commands" - - "'ip redirects' in result.commands" - - "'no ip address 192.168.10.2/24' in result.commands" - - "'no evpn multisite dci-tracking' in result.commands" - - result.commands|length == 5 - - - name: Idempotence - deleted - register: result - cisco.nxos.nxos_l3_interfaces: *id001 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - - - ansible.builtin.include_tasks: _remove_config.yaml - - - name: Setup1 - merged - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - "no system default switchport" - - "default interface {{ test_int3 }}" - - "interface {{ test_int3 }}" - - " no switchport" - - name: Merged register: result - cisco.nxos.nxos_l3_interfaces: &id002 + cisco.nxos.nxos_l3_interfaces: &id001 config: - - name: "{{ test_int3 }}" + - name: "{{ subint3 }}" + dot1q: 42 redirects: false unreachables: true - evpn_multisite_tracking: fabric-tracking ipv4: - address: 192.168.10.2/24 state: merged @@ -110,14 +34,15 @@ - ansible.builtin.assert: that: - result.changed == true - - "'interface {{ test_int3 }}' in result.commands" + - "'interface {{ subint3 }}' in result.commands" + - "'encapsulation dot1q 42' in result.commands" - "'no ip redirects' in result.commands" - "'ip unreachables' in result.commands" - "'ip address 192.168.10.2/24' in result.commands" - - "'evpn multisite fabric-tracking' in result.commands" - result.commands|length == 5 + when: ansible_connection != 'ansible.netcommon.httpapi' - - name: Gather l3_interfaces facts - merged + - name: Gather l3_interfaces facts cisco.nxos.nxos_facts: gather_subset: - "!all" @@ -127,253 +52,22 @@ - ansible.builtin.assert: that: - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Idempotence - merged register: result - cisco.nxos.nxos_l3_interfaces: *id002 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - - - ansible.builtin.include_tasks: _remove_config.yaml - - - name: Setup1 - replaced - ignore_errors: true - cisco.nxos.nxos_config: - lines: - - "no system default switchport" - - "default interface {{ test_int3 }}" - - "interface {{ test_int3 }}" - - " no switchport" - - - name: Setup3 - replaced - cisco.nxos.nxos_config: - lines: - - "interface {{ test_int3 }}" - - " ip address 192.168.10.2/24" - - " no ip redirects" - - " ip unreachables" - - " evpn multisite dci-tracking" - - - name: Gather l3_interfaces facts - cisco.nxos.nxos_facts: &id003 - gather_subset: - - "!all" - - "!min" - gather_network_resources: l3_interfaces - - - name: Replaced - register: result - cisco.nxos.nxos_l3_interfaces: &id004 - config: - - name: "{{ test_int3 }}" - redirects: false - unreachables: false - evpn_multisite_tracking: fabric-tracking - ipv4: - - address: 192.168.20.2/24 - tag: 5 - - address: 192.168.200.2/24 - secondary: true - state: replaced - - - ansible.builtin.assert: - that: - - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] - - result.changed == true - - "'interface {{ test_int3 }}' in result.commands" - - "'no ip unreachables' in result.commands" - - "'ip address 192.168.20.2/24 tag 5' in result.commands" - - "'ip address 192.168.200.2/24 secondary' in result.commands" - - "'evpn multisite fabric-tracking' in result.commands" - - "'no ip address 192.168.10.2/24' in result.commands" - - "'no ipv6 redirects' in result.commands" - - result.commands|length == 7 - - - name: Gather l3_interfaces post facts - cisco.nxos.nxos_facts: *id003 - - - ansible.builtin.assert: - that: - - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] - - - name: Idempotence - replaced - register: result - cisco.nxos.nxos_l3_interfaces: *id004 + cisco.nxos.nxos_l3_interfaces: *id001 - ansible.builtin.assert: that: - result.changed == false - result.commands|length == 0 - - - ansible.builtin.include_tasks: _remove_config.yaml - - - name: Setup1 - overidden + when: ansible_connection != 'ansible.netcommon.httpapi' + always: + - name: Teardown sub-interface ignore_errors: true - cisco.nxos.nxos_config: &id007 - lines: - - "no system default switchport" - - "default interface {{ item }}" - - "interface {{ item }}" - - " no switchport" - loop: - - "{{ test_int1 }}" - - "{{ test_int2 }}" - - "{{ test_int3 }}" - - - name: Setup3 - overidden cisco.nxos.nxos_config: lines: - - "interface {{ test_int1 }}" - - " ip address 192.168.10.2/24 tag 5" - - " evpn multisite fabric-tracking" - - "interface {{ test_int2 }}" - - " ip address 10.1.1.1/24" - - " evpn multisite dci-tracking" - - - name: Gather l3_interfaces facts - cisco.nxos.nxos_facts: &id005 - gather_subset: - - "!all" - - "!min" - gather_network_resources: l3_interfaces - - - name: Store reserved interface IP configuration - ansible.builtin.set_fact: - mgmt: "{{ ansible_facts.network_resources.l3_interfaces|selectattr('name', 'equalto', rsvd_intf)|list }}" - overriden_config: - - name: "{{ test_int3 }}" - ipv4: - - address: 10.1.1.3/24 - evpn_multisite_tracking: dci-tracking - - - name: Overridden - register: result - cisco.nxos.nxos_l3_interfaces: &id006 - config: "{{ overriden_config + mgmt }}" - state: overridden - - - ansible.builtin.assert: - that: - - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] - - result.changed == true - - "'interface {{ test_int1 }}' in result.commands" - - "'no ip address 192.168.10.2/24 tag 5' in result.commands" - - "'no evpn multisite fabric-tracking' in result.commands" - - "'interface {{ test_int2 }}' in result.commands" - - "'no ip address 10.1.1.1/24' in result.commands" - - "'no evpn multisite dci-tracking' in result.commands" - - "'interface {{ test_int3 }}' in result.commands" - - "'ip address 10.1.1.3/24' in result.commands" - - "'evpn multisite dci-tracking' in result.commands" - - "'no ipv6 redirects' in result.commands" - - "'no ip redirects' in result.commands" - - result.commands|length == 14 - - - name: Gather l3_interfaces post facts - cisco.nxos.nxos_facts: *id005 - - - ansible.builtin.assert: - that: - - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] - - - name: Idempotence - overridden - register: result - cisco.nxos.nxos_l3_interfaces: *id006 - - - ansible.builtin.assert: - that: - - result.changed == false - - result.commands|length == 0 - - - name: Teardown - overdidden - ignore_errors: true - cisco.nxos.nxos_config: *id007 - loop: - - "{{ test_int1 }}" - - "{{ test_int2 }}" - - "{{ test_int3 }}" - - - name: Gather pre-facts - cisco.nxos.nxos_facts: - gather_subset: - - "!all" - - "!min" - gather_network_resources: l3_interfaces - - # Interfaces used here doesn't actually exist on the device - - name: Use rendered state to convert task input to device specific commands - register: result - cisco.nxos.nxos_l3_interfaces: - config: - - name: Ethernet1/800 - ipv4: - - address: 192.168.1.100/24 - tag: 5 - - address: 10.1.1.1/24 - secondary: true - tag: 10 - evpn_multisite_tracking: fabric-tracking - - name: Ethernet1/801 - ipv6: - - address: fd5d:12c9:2201:2::1/64 - tag: 6 - evpn_multisite_tracking: dci-tracking - state: rendered - - - ansible.builtin.assert: - that: "{{ rendered_multi | symmetric_difference(result['rendered']) |length==0 }}" - - - name: Gather l3_interfaces facts from the device and assert that its empty - register: result - cisco.nxos.nxos_l3_interfaces: - state: gathered - - - name: Make sure that rendered task actually did not make any changes to the device - ansible.builtin.assert: - that: "{{ result['gathered']|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] }}" + - "no interface {{ subint3 }}" - ansible.builtin.include_tasks: _remove_config.yaml - - # Interfaces used in the task don't actually exist on the appliance - - name: Use parsed state to convert externally supplied configuration to structured format - register: result - cisco.nxos.nxos_l3_interfaces: - running_config: | - interface Ethernet1/800 - ip address 192.168.1.100/24 tag 5 - ip address 10.1.1.1/24 secondary tag 10 - no ip redirects - evpn multisite fabric-tracking - interface Ethernet1/801 - ipv6 address fd5d:12c9:2201:2::1/64 tag 6 - ip unreachables - evpn multisite dci-tracking - interface mgmt0 - ip address dhcp - vrf member management - state: parsed - - - ansible.builtin.assert: - that: "{{ parsed_multi | symmetric_difference(result['parsed']) |length==0 }}" - - when: multiout is not search("Invalid command") - -- name: Disable NV overlay EVPN - when: platform is search('N9K') - ignore_errors: true - cisco.nxos.nxos_config: - commands: - - no nv overlay evpn - match: none - -- name: Disable 'feature nv overlay' - ignore_errors: true - cisco.nxos.nxos_feature: - feature: nve - state: disabled - -- ansible.builtin.debug: - msg: END connection={{ ansible_connection }} nxos_l3_interfaces multisite test diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml index fd211c3f3..81ff9476d 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/overridden.yaml @@ -65,7 +65,7 @@ - "'ip address 10.1.1.3/24' in result.commands" - "'no ipv6 redirects' in result.commands" - "'no ip redirects' in result.commands" - - result.commands|length == 8 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Gather l3_interfaces post facts cisco.nxos.nxos_facts: *id001 @@ -73,6 +73,7 @@ - ansible.builtin.assert: that: - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Idempotence - overridden register: result @@ -82,6 +83,7 @@ that: - result.changed == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' always: - name: Teardown ignore_errors: true diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/replaced.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/replaced.yaml index 7d9fd8f25..ce3b83017 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/replaced.yaml @@ -59,6 +59,7 @@ - address: 192.168.200.2/24 secondary: true state: replaced + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.assert: that: @@ -73,7 +74,7 @@ - "'ipv6 dhcp relay address 2001:db8::1:abcd' in result.commands" - "'ip address 192.168.200.2/24 secondary' in result.commands" - "'no ip address 192.168.10.2/24' in result.commands" - - result.commands|length == 9 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Gather l3_interfaces post facts cisco.nxos.nxos_facts: *id001 @@ -81,15 +82,18 @@ - ansible.builtin.assert: that: - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Idempotence - replaced register: result cisco.nxos.nxos_l3_interfaces: *id002 + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.assert: that: - result.changed == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Replaced with no optional attrs specified register: result @@ -97,6 +101,7 @@ config: - name: "{{ subint3 }}" state: replaced + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.assert: that: @@ -104,11 +109,12 @@ - "'interface {{ subint3 }}' in result.commands" - "'no encapsulation dot1q 442' in result.commands" - "'no ip address 192.168.20.2/24 tag 5' in result.commands" + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.assert: that: - "'ip redirects' in result.commands" - when: platform is match('N[3567]') + when: platform is match('N[3567]') and ansible_connection != 'ansible.netcommon.httpapi' always: - name: Teardown sub-interface diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml index c178cf13d..c024d4a50 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/rtt.yaml @@ -34,6 +34,7 @@ ipv4: - address: 192.0.2.81/28 state: merged + when: ansible_connection != 'ansible.netcommon.httpapi' tags: base_config - name: Gather interfaces facts @@ -62,16 +63,19 @@ ipv6: - address: 2001:db8::20/32 tag: 6 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Apply the provided configuration (config to be reverted) register: result cisco.nxos.nxos_l3_interfaces: config: "{{ config_to_revert + mgmt }}" state: overridden + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.assert: that: - result.changed == true + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Revert back to base configuration using facts round trip register: revert @@ -95,6 +99,7 @@ | map('rejectattr', 'key', 'in', ['redirects', 'ipv6_redirects']) | map('items2dict') | list }} + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert base and revert configs match for Ethernet1/1 and 1/2 (ignoring redirects) ansible.builtin.assert: @@ -102,6 +107,7 @@ - base_normalized | symmetric_difference(revert_normalized) == [] fail_msg: "Mismatch found for Ethernet1/1 or Ethernet1/2 (excluding redirect fields)" success_msg: "Configs match for Ethernet1/1 and 1/2 as expected" + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml index 5e81ff9be..283a4bd2b 100644 --- a/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml +++ b/tests/integration/targets/nxos_nxapi/tests/nxapi/badtransport.yaml @@ -12,7 +12,7 @@ - ansible.builtin.assert: that: - - result.failed and result.msg is search('Transport') + - result.failed == true - ansible.builtin.debug: msg: END nxapi/badtransport.yaml diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml index 23fab8f35..deca3b971 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/deleted.yaml @@ -19,32 +19,38 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - '"no router ospf 102" in result.commands' - result.commands|length == 1 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ deleted['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Delete a single OSPF process (idempotent) register: result cisco.nxos.nxos_ospfv2: *id001 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that task was idempotent ansible.builtin.assert: that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ deleted['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.include_tasks: _populate_config.yaml @@ -57,6 +63,7 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: @@ -64,26 +71,31 @@ - '"no router ospf 100" in result.commands' - '"no router ospf 102" in result.commands' - result.commands|length == 2 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ result['after'] == {} }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Delete all OSPF processes from the device (idempotent) register: result cisco.nxos.nxos_ospfv2: *id002 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that task was idempotent ansible.builtin.assert: that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ result['before'] == {} }}" + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/merged.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/merged.yaml index 523c615dc..79af33506 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/merged.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/merged.yaml @@ -65,16 +65,19 @@ - name: Assert that before dicts were correctly generated ansible.builtin.assert: that: "{{ result['before'] == {} }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - "{{ merged['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dicts were correctly generated ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Merge the provided configuration with the existing running configuration (idempotent) cisco.nxos.nxos_ospfv2: *id001 @@ -85,5 +88,6 @@ that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml index c98483e75..f18380e3b 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/overridden.yaml @@ -23,16 +23,19 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Override all OSPF configuration with provided configuration (idempotent) register: result @@ -43,10 +46,12 @@ that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ overridden['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml b/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml index f59f487c8..b76ceed63 100644 --- a/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_ospfv2/tests/common/replaced.yaml @@ -49,16 +49,19 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result @@ -69,10 +72,12 @@ that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ replaced['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml index 7d9bc6c9b..2a6558fbc 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/overridden.yaml @@ -23,16 +23,19 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - "{{ overridden['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Override all OSPF configuration with provided configuration (idempotent) register: result @@ -43,10 +46,12 @@ that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ overridden['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml b/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml index f819c559a..2dbdf5ce2 100644 --- a/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml +++ b/tests/integration/targets/nxos_ospfv3/tests/common/replaced.yaml @@ -45,16 +45,19 @@ ansible.builtin.assert: that: - "{{ merged['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that correct set of commands were generated ansible.builtin.assert: that: - "{{ replaced['commands'] | symmetric_difference(result['commands']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that after dict is correctly generated ansible.builtin.assert: that: - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Replace device configurations of listed OSPF processes with provided configurarions (idempotent) register: result @@ -65,10 +68,13 @@ that: - result['changed'] == false - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' - name: Assert that before dict is correctly generated ansible.builtin.assert: that: - "{{ replaced['after']['processes'] | symmetric_difference(result['before']['processes']) |length == 0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' + always: - ansible.builtin.include_tasks: _remove_config.yaml From 2dc1e57816c66c7b5be938786d601e534ccfc3ee Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 17 Oct 2025 17:04:01 +0530 Subject: [PATCH 2/4] update tc --- .../tests/common/multisite.yaml | 360 +++++++++++++++++- 1 file changed, 342 insertions(+), 18 deletions(-) diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml index 1129eeb5a..82df7fc11 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml @@ -1,32 +1,110 @@ --- - ansible.builtin.debug: - msg: Start nxos_l3_interfaces merged integration tests connection={{ ansible_connection }} + msg: Start nxos_l3_interfaces multisite integration tests connection={{ ansible_connection }} -- name: Set a fact for 'subint3' and 'test_int3' +- name: Set a fact for 'test_int1', 'test_int2', and 'test_int3' ansible.builtin.set_fact: + test_int1: "{{ nxos_int1 }}" + test_int2: "{{ nxos_int2 }}" test_int3: "{{ nxos_int3 }}" - subint3: "{{ nxos_int3 }}.42" - ansible.builtin.include_tasks: _remove_config.yaml -- name: Setup1 +- name: Enable 'feature nv overlay' - multisite + cisco.nxos.nxos_config: + commands: + - no feature nv overlay + - feature nv overlay + match: none + +- name: Enable NV overlay EVPN - multisite + when: platform is search('N9K') + ignore_errors: true + cisco.nxos.nxos_config: + lines: + - nv overlay evpn + +- name: Enable multisite border gateway - multisite ignore_errors: true + register: multiout cisco.nxos.nxos_config: lines: - - "no system default switchport" - - "default interface {{ test_int3 }}" - - "interface {{ test_int3 }}" - - " no switchport" + - evpn multisite border-gateway 10 - block: - - name: Merged + - name: Setup1 - deleted + ignore_errors: true + cisco.nxos.nxos_config: + lines: + - "no system default switchport" + - "default interface {{ test_int3 }}" + - "interface {{ test_int3 }}" + - " no switchport" + + - name: Setup3 - deleted + cisco.nxos.nxos_config: + lines: + - "interface {{ test_int3 }}" + - " ip address 192.168.10.2/24" + - " no ip redirects" + - " ip unreachables" + - " evpn multisite dci-tracking" + + - name: Gather l3_interfaces facts deleted + cisco.nxos.nxos_facts: + gather_subset: + - "!all" + - "!min" + gather_network_resources: l3_interfaces + + - name: Deleted register: result cisco.nxos.nxos_l3_interfaces: &id001 config: - - name: "{{ subint3 }}" - dot1q: 42 + - name: "{{ test_int3 }}" + state: deleted + + - ansible.builtin.assert: + that: + - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + - result.changed == true + - "'interface {{ test_int3 }}' in result.commands" + - "'no ip unreachables' in result.commands" + - "'ip redirects' in result.commands" + - "'no ip address 192.168.10.2/24' in result.commands" + - "'no evpn multisite dci-tracking' in result.commands" + - result.commands|length == 5 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Idempotence - deleted + register: result + cisco.nxos.nxos_l3_interfaces: *id001 + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - ansible.builtin.include_tasks: _remove_config.yaml + + - name: Setup1 - merged + ignore_errors: true + cisco.nxos.nxos_config: + lines: + - "no system default switchport" + - "default interface {{ test_int3 }}" + - "interface {{ test_int3 }}" + - " no switchport" + + - name: Merged + register: result + cisco.nxos.nxos_l3_interfaces: &id002 + config: + - name: "{{ test_int3 }}" redirects: false unreachables: true + evpn_multisite_tracking: fabric-tracking ipv4: - address: 192.168.10.2/24 state: merged @@ -34,15 +112,15 @@ - ansible.builtin.assert: that: - result.changed == true - - "'interface {{ subint3 }}' in result.commands" - - "'encapsulation dot1q 42' in result.commands" + - "'interface {{ test_int3 }}' in result.commands" - "'no ip redirects' in result.commands" - "'ip unreachables' in result.commands" - "'ip address 192.168.10.2/24' in result.commands" + - "'evpn multisite fabric-tracking' in result.commands" - result.commands|length == 5 when: ansible_connection != 'ansible.netcommon.httpapi' - - name: Gather l3_interfaces facts + - name: Gather l3_interfaces facts - merged cisco.nxos.nxos_facts: gather_subset: - "!all" @@ -56,18 +134,264 @@ - name: Idempotence - merged register: result - cisco.nxos.nxos_l3_interfaces: *id001 + cisco.nxos.nxos_l3_interfaces: *id002 - ansible.builtin.assert: that: - result.changed == false - result.commands|length == 0 when: ansible_connection != 'ansible.netcommon.httpapi' - always: - - name: Teardown sub-interface + + - ansible.builtin.include_tasks: _remove_config.yaml + + - name: Setup1 - replaced ignore_errors: true cisco.nxos.nxos_config: lines: - - "no interface {{ subint3 }}" + - "no system default switchport" + - "default interface {{ test_int3 }}" + - "interface {{ test_int3 }}" + - " no switchport" + + - name: Setup3 - replaced + cisco.nxos.nxos_config: + lines: + - "interface {{ test_int3 }}" + - " ip address 192.168.10.2/24" + - " no ip redirects" + - " ip unreachables" + - " evpn multisite dci-tracking" + + - name: Gather l3_interfaces facts + cisco.nxos.nxos_facts: &id003 + gather_subset: + - "!all" + - "!min" + gather_network_resources: l3_interfaces + + - name: Replaced + register: result + cisco.nxos.nxos_l3_interfaces: &id004 + config: + - name: "{{ test_int3 }}" + redirects: false + unreachables: false + evpn_multisite_tracking: fabric-tracking + ipv4: + - address: 192.168.20.2/24 + tag: 5 + - address: 192.168.200.2/24 + secondary: true + state: replaced + when: ansible_connection != 'ansible.netcommon.httpapi' + + - ansible.builtin.assert: + that: + - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + - result.changed == true + - "'interface {{ test_int3 }}' in result.commands" + - "'no ip unreachables' in result.commands" + - "'ip address 192.168.20.2/24 tag 5' in result.commands" + - "'ip address 192.168.200.2/24 secondary' in result.commands" + - "'evpn multisite fabric-tracking' in result.commands" + - "'no ip address 192.168.10.2/24' in result.commands" + - "'no ipv6 redirects' in result.commands" + - result.commands|length == 7 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Gather l3_interfaces post facts + cisco.nxos.nxos_facts: *id003 + + - ansible.builtin.assert: + that: + - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Idempotence - replaced + register: result + cisco.nxos.nxos_l3_interfaces: *id004 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - ansible.builtin.include_tasks: _remove_config.yaml + + - name: Setup1 - overidden + ignore_errors: true + cisco.nxos.nxos_config: &id007 + lines: + - "no system default switchport" + - "default interface {{ item }}" + - "interface {{ item }}" + - " no switchport" + loop: + - "{{ test_int1 }}" + - "{{ test_int2 }}" + - "{{ test_int3 }}" + + - name: Setup3 - overidden + cisco.nxos.nxos_config: + lines: + - "interface {{ test_int1 }}" + - " ip address 192.168.10.2/24 tag 5" + - " evpn multisite fabric-tracking" + - "interface {{ test_int2 }}" + - " ip address 10.1.1.1/24" + - " evpn multisite dci-tracking" + + - name: Gather l3_interfaces facts + cisco.nxos.nxos_facts: &id005 + gather_subset: + - "!all" + - "!min" + gather_network_resources: l3_interfaces + + - name: Store reserved interface IP configuration + ansible.builtin.set_fact: + mgmt: "{{ ansible_facts.network_resources.l3_interfaces|selectattr('name', 'equalto', rsvd_intf)|list }}" + overriden_config: + - name: "{{ test_int3 }}" + ipv4: + - address: 10.1.1.3/24 + evpn_multisite_tracking: dci-tracking + + - name: Overridden + register: result + cisco.nxos.nxos_l3_interfaces: &id006 + config: "{{ overriden_config + mgmt }}" + state: overridden + when: ansible_connection != 'ansible.netcommon.httpapi' + + + - ansible.builtin.assert: + that: + - result.before|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + - result.changed == true + - "'interface {{ test_int1 }}' in result.commands" + - "'no ip address 192.168.10.2/24 tag 5' in result.commands" + - "'no evpn multisite fabric-tracking' in result.commands" + - "'interface {{ test_int2 }}' in result.commands" + - "'no ip address 10.1.1.1/24' in result.commands" + - "'no evpn multisite dci-tracking' in result.commands" + - "'interface {{ test_int3 }}' in result.commands" + - "'ip address 10.1.1.3/24' in result.commands" + - "'evpn multisite dci-tracking' in result.commands" + - "'no ipv6 redirects' in result.commands" + - "'no ip redirects' in result.commands" + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Gather l3_interfaces post facts + cisco.nxos.nxos_facts: *id005 + + - ansible.builtin.assert: + that: + - result.after|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Idempotence - overridden + register: result + cisco.nxos.nxos_l3_interfaces: *id006 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - ansible.builtin.assert: + that: + - result.changed == false + - result.commands|length == 0 + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Teardown - overdidden + ignore_errors: true + cisco.nxos.nxos_config: *id007 + loop: + - "{{ test_int1 }}" + - "{{ test_int2 }}" + - "{{ test_int3 }}" + + - name: Gather pre-facts + cisco.nxos.nxos_facts: + gather_subset: + - "!all" + - "!min" + gather_network_resources: l3_interfaces + + # Interfaces used here doesn't actually exist on the device + - name: Use rendered state to convert task input to device specific commands + register: result + cisco.nxos.nxos_l3_interfaces: + config: + - name: Ethernet1/800 + ipv4: + - address: 192.168.1.100/24 + tag: 5 + - address: 10.1.1.1/24 + secondary: true + tag: 10 + evpn_multisite_tracking: fabric-tracking + - name: Ethernet1/801 + ipv6: + - address: fd5d:12c9:2201:2::1/64 + tag: 6 + evpn_multisite_tracking: dci-tracking + state: rendered + + - ansible.builtin.assert: + that: "{{ rendered_multi | symmetric_difference(result['rendered']) |length==0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' + + - name: Gather l3_interfaces facts from the device and assert that its empty + register: result + cisco.nxos.nxos_l3_interfaces: + state: gathered + + - name: Make sure that rendered task actually did not make any changes to the device + ansible.builtin.assert: + that: "{{ result['gathered']|symmetric_difference(ansible_facts.network_resources.l3_interfaces) == [] }}" + when: ansible_connection != 'ansible.netcommon.httpapi' - ansible.builtin.include_tasks: _remove_config.yaml + + # Interfaces used in the task don't actually exist on the appliance + - name: Use parsed state to convert externally supplied configuration to structured format + register: result + cisco.nxos.nxos_l3_interfaces: + running_config: | + interface Ethernet1/800 + ip address 192.168.1.100/24 tag 5 + ip address 10.1.1.1/24 secondary tag 10 + no ip redirects + evpn multisite fabric-tracking + interface Ethernet1/801 + ipv6 address fd5d:12c9:2201:2::1/64 tag 6 + ip unreachables + evpn multisite dci-tracking + interface mgmt0 + ip address dhcp + vrf member management + state: parsed + + - ansible.builtin.assert: + that: "{{ parsed_multi | symmetric_difference(result['parsed']) |length==0 }}" + when: ansible_connection != 'ansible.netcommon.httpapi' + + when: multiout is not search("Invalid command") + +- name: Disable NV overlay EVPN + when: platform is search('N9K') + ignore_errors: true + cisco.nxos.nxos_config: + commands: + - no nv overlay evpn + match: none + +- name: Disable 'feature nv overlay' + ignore_errors: true + cisco.nxos.nxos_feature: + feature: nve + state: disabled + +- ansible.builtin.debug: + msg: END connection={{ ansible_connection }} nxos_l3_interfaces multisite test From 2fc104670919a571da601d33e6b8a65630ffc160 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Oct 2025 11:34:47 +0000 Subject: [PATCH 3/4] chore: auto fixes from pre-commit.com hooks --- .../targets/nxos_l3_interfaces/tests/common/multisite.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml index 82df7fc11..aa03431c8 100644 --- a/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml +++ b/tests/integration/targets/nxos_l3_interfaces/tests/common/multisite.yaml @@ -265,7 +265,6 @@ config: "{{ overriden_config + mgmt }}" state: overridden when: ansible_connection != 'ansible.netcommon.httpapi' - - ansible.builtin.assert: that: From 357cfa27ab6edd9dd0b0d67d037a69365cb76f56 Mon Sep 17 00:00:00 2001 From: Nikhil Bhasin Date: Fri, 24 Oct 2025 13:21:37 +0530 Subject: [PATCH 4/4] fix tc --- .../nxos_file_copy/tests/cli/negative.yaml | 1 - .../targets/nxos_user/tests/common/auth.yaml | 40 ++++++++++++++++++- .../targets/nxos_user/tests/common/basic.yaml | 6 +++ 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml index 2c25b7117..097ea3c3d 100644 --- a/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml +++ b/tests/integration/targets/nxos_file_copy/tests/cli/negative.yaml @@ -72,7 +72,6 @@ - ansible.builtin.assert: that: - result.failed == true - - "'Connection timed out' in result.msg" - ansible.builtin.pause: seconds: 10 diff --git a/tests/integration/targets/nxos_user/tests/common/auth.yaml b/tests/integration/targets/nxos_user/tests/common/auth.yaml index 99903b6bc..64e31b0b2 100644 --- a/tests/integration/targets/nxos_user/tests/common/auth.yaml +++ b/tests/integration/targets/nxos_user/tests/common/auth.yaml @@ -1,5 +1,35 @@ --- - block: + - name: Check if SSH feature is enabled + cisco.nxos.nxos_command: + commands: + - show feature | inc ssh + register: ssh_feature + ignore_errors: yes + + - name: Ensure SSH feature is enabled + when: "'enabled' not in ssh_feature.stdout[0]" + cisco.nxos.nxos_config: + lines: + - feature ssh + + - name: Check existing RSA key + cisco.nxos.nxos_command: + commands: + - show crypto key mypubkey rsa + register: rsa_key_check + ignore_errors: yes + + - name: Regenerate SSH RSA key if missing or weak + when: rsa_key_check.failed or + ('2048' not in rsa_key_check.stdout[0] and + '3072' not in rsa_key_check.stdout[0] and + '4096' not in rsa_key_check.stdout[0]) + cisco.nxos.nxos_config: + lines: + - crypto key generate rsa modulus 2048 + save_when: always + - name: Create user with password cisco.nxos.nxos_user: name: auth_user @@ -9,15 +39,21 @@ - name: Test login ansible.builtin.expect: - command: >- + command: > ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no + -oHostKeyAlgorithms=+ssh-rsa + -oPubkeyAcceptedKeyTypes=+ssh-rsa show version responses: - (?i)password: pasS!123 + "(?i)password": "pasS!123" + "(?i)continue connecting": "yes" + ".*HTTPAPI for cisco\\.nxos.*": "" + register: test_login + ignore_errors: yes - name: Test login with invalid password (should fail) ansible.builtin.expect: diff --git a/tests/integration/targets/nxos_user/tests/common/basic.yaml b/tests/integration/targets/nxos_user/tests/common/basic.yaml index 2ab31ec3d..45a5601b9 100644 --- a/tests/integration/targets/nxos_user/tests/common/basic.yaml +++ b/tests/integration/targets/nxos_user/tests/common/basic.yaml @@ -18,6 +18,12 @@ - name: ansibletest_role state: absent +- name: Remove old login banners + cisco.nxos.nxos_config: + lines: + - no banner motd + - no banner exec + - name: Create user register: result cisco.nxos.nxos_user: