diff options
Diffstat (limited to 'ansible_collections/cisco/ios/tests/integration/targets')
84 files changed, 2471 insertions, 326 deletions
diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg index 166af7ee7..b76fdcae3 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/tests/cli/_parsed.cfg @@ -1,10 +1,53 @@ -Extended IP access list 110 - 10 deny icmp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 echo dscp ef ttl eq 10 -Extended IP access list 123 - 10 deny tcp 198.51.100.0 0.0.0.255 198.51.101.0 0.0.0.255 eq telnet ack tos 12 - 20 deny tcp 192.0.3.0 0.0.0.255 192.0.4.0 0.0.0.255 eq www ack dscp ef ttl lt 20 -Extended IP access list test_acl - 10 deny tcp 192.0.2.0 0.0.0.255 192.0.3.0 0.0.0.255 eq www fin option traceroute ttl eq 10 -IPv6 access list R1_TRAFFIC - deny tcp any eq www any eq telnet ack dscp af11 sequence 10 -access-list 110 remark test a remark. +ip access-list extended NET-MGMT-VTY + 10 permit tcp 10.57.66.243 0.0.0.7 any eq 22 + 20 permit tcp host 10.160.114.111 any eq 22 + 30 permit tcp host 10.160.115.22 any eq 22 + 40 deny ip any any log +ip access-list extended TEST + 10 remark FIRST REMARK BEFORE LINE 10 + 10 remark ============ + 10 remark ALLOW HOST FROM BUILDING 10 + 10 permit ip host 1.1.1.1 any + 20 remark FIRST REMARK BEFORE LINE 20 + 20 remark ============ + 20 remark ALLOW HOST FROM BUILDING 20 + 20 permit ip host 2.2.2.2 any + 30 remark FIRST REMARK BEFORE LINE 30 + 30 remark ============ + 30 remark ALLOW NEW HOST FROM BUILDING 10 + 30 permit ip host 3.3.3.3 any + remark FIRST REMARK AT END OF ACL + remark SECOND REMARK AT END OF ACL +ip access-list extended empty_ip_ex_acl + remark empty remark 1 + remark empty remark 2 + remark empty remark never ends +ip access-list extended mytest + 100 remark I am a test ace + 100 remark I am right after the test ace + 100 remark I third the test ace + 100 permit ip host 100.100.100.100 any + 110 remark I am the next test ace + 110 remark I am the next ace to the next ace + 110 permit ip host 10.40.150.0 any + remark I am the peace ace + remark Peace out +ip access-list standard 42 + 10 permit 10.182.250.0 0.0.0.255 +ip access-list extended 199 + 10 permit ip 10.40.150.0 0.0.0.255 any + 20 permit ip any 10.40.150.0 0.0.0.255 +ipv6 access-list R1_TRAFFIC + sequence 10 permit ipv6 2001:ABAD:BEEF:1221::/64 any + sequence 20 deny tcp host 2001:ABAD:BEEF:2345::1 host 2001:ABAD:BEEF:1212::1 eq www +ipv6 access-list empty_ipv6_acl + sequence 10 remark empty remark 1 + sequence 20 remark empty remark 2 + sequence 30 remark empty remark never ends +ipv6 access-list ipv6_acl + sequence 10 remark I am a ipv6 ace + sequence 20 remark I am test + sequence 30 permit tcp any any + sequence 40 permit udp any any + sequence 50 remark I am new set of ipv6 ace + sequence 60 permit icmp any any diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml index 799b166a3..2d324ebe1 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_acls/vars/main.yaml @@ -154,100 +154,207 @@ parsed: - acls: - aces: - destination: - address: 192.0.3.0 - wildcard_bits: 0.0.0.255 - dscp: ef - grant: deny - protocol: icmp - protocol_options: - icmp: - echo: true + any: true + grant: permit + protocol: ip sequence: 10 source: - address: 192.0.2.0 + address: 10.40.150.0 wildcard_bits: 0.0.0.255 - ttl: - eq: 10 - - remarks: - - "test a remark." + - destination: + address: 10.40.150.0 + wildcard_bits: 0.0.0.255 + grant: permit + protocol: ip + sequence: 20 + source: + any: true acl_type: extended - name: "110" + name: "199" + - aces: + - grant: permit + sequence: 10 + source: + address: 10.182.250.0 + wildcard_bits: 0.0.0.255 + acl_type: standard + name: "42" - aces: - destination: - address: 198.51.101.0 + any: true port_protocol: - eq: telnet - wildcard_bits: 0.0.0.255 - grant: deny + eq: "22" + grant: permit protocol: tcp - protocol_options: - tcp: - ack: true sequence: 10 source: - address: 198.51.100.0 - wildcard_bits: 0.0.0.255 - tos: - service_value: 12 + address: 10.57.66.243 + wildcard_bits: 0.0.0.7 - destination: - address: 192.0.4.0 + any: true port_protocol: - eq: www - wildcard_bits: 0.0.0.255 - dscp: ef - grant: deny + eq: "22" + grant: permit protocol: tcp - protocol_options: - tcp: - ack: true sequence: 20 source: - address: 192.0.3.0 - wildcard_bits: 0.0.0.255 - ttl: - lt: 20 - acl_type: extended - name: "123" - - aces: + host: 10.160.114.111 - destination: - address: 192.0.3.0 + any: true port_protocol: - eq: www - wildcard_bits: 0.0.0.255 - grant: deny - option: - traceroute: true + eq: "22" + grant: permit protocol: tcp - protocol_options: - tcp: - fin: true + sequence: 30 + source: + host: 10.160.115.22 + - destination: + any: true + grant: deny + log: + set: true + protocol: ip + sequence: 40 + source: + any: true + acl_type: extended + name: NET-MGMT-VTY + - aces: + - destination: + any: true + grant: permit + protocol: ip + remarks: + - FIRST REMARK BEFORE LINE 10 + - "============" + - ALLOW HOST FROM BUILDING 10 sequence: 10 source: - address: 192.0.2.0 - wildcard_bits: 0.0.0.255 - ttl: - eq: 10 + host: 1.1.1.1 + - destination: + any: true + grant: permit + protocol: ip + remarks: + - FIRST REMARK BEFORE LINE 20 + - "============" + - ALLOW HOST FROM BUILDING 20 + sequence: 20 + source: + host: 2.2.2.2 + - destination: + any: true + grant: permit + protocol: ip + remarks: + - FIRST REMARK BEFORE LINE 30 + - "============" + - ALLOW NEW HOST FROM BUILDING 10 + sequence: 30 + source: + host: 3.3.3.3 + - remarks: + - FIRST REMARK AT END OF ACL + - SECOND REMARK AT END OF ACL acl_type: extended - name: test_acl + name: TEST + - aces: + - remarks: + - empty remark 1 + - empty remark 2 + - empty remark never ends + acl_type: extended + name: empty_ip_ex_acl + - aces: + - destination: + any: true + grant: permit + protocol: ip + remarks: + - I am a test ace + - I am right after the test ace + - I third the test ace + sequence: 100 + source: + host: 100.100.100.100 + - destination: + any: true + grant: permit + protocol: ip + remarks: + - I am the next test ace + - I am the next ace to the next ace + sequence: 110 + source: + host: 10.40.150.0 + - remarks: + - I am the peace ace + - Peace out + acl_type: extended + name: mytest afi: ipv4 - acls: - aces: - destination: any: true + grant: permit + protocol: ipv6 + sequence: 10 + source: + address: 2001:ABAD:BEEF:1221::/64 + - destination: + host: 2001:ABAD:BEEF:1212::1 port_protocol: - eq: telnet - dscp: af11 + eq: www grant: deny protocol: tcp - protocol_options: - tcp: - ack: true + sequence: 20 + source: + host: 2001:ABAD:BEEF:2345::1 + name: R1_TRAFFIC + - aces: + - remarks: + - empty remark 1 sequence: 10 + - remarks: + - empty remark 2 + sequence: 20 + - remarks: + - empty remark never ends + sequence: 30 + name: empty_ipv6_acl + - aces: + - remarks: + - I am a ipv6 ace + sequence: 10 + - remarks: + - I am test + sequence: 20 + - destination: + any: true + grant: permit + protocol: tcp + sequence: 30 source: any: true - port_protocol: - eq: www - name: R1_TRAFFIC + - destination: + any: true + grant: permit + protocol: udp + sequence: 40 + source: + any: true + - remarks: + - I am new set of ipv6 ace + sequence: 50 + - destination: + any: true + grant: permit + protocol: icmp + sequence: 60 + source: + any: true + name: ipv6_acl afi: ipv6 rendered: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml index 4ac501796..843fc15bc 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/_populate_config.yaml @@ -1,6 +1,13 @@ --- - ansible.builtin.include_tasks: _initial_vrf_setup.yaml - ansible.builtin.include_tasks: _ospf_proc_setup.yaml + +- name: Enable routing + cisco.ios.ios_config: + lines: + - ip routing + - ipv6 unicast-routing + - name: Populate BGP address family configuration cisco.ios.ios_bgp_address_family: config: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml index c09e95661..81aa0512d 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/tests/cli/merged.yaml @@ -11,6 +11,22 @@ cisco.ios.ios_bgp_address_family: &id001 config: address_family: + - afi: l2vpn + safi: evpn + neighbor: + - address: 198.51.100.1 + activate: true + inherit: LEAF-EVPN-PEER-POLICY + - afi: ipv4 + vrf: green + redistribute: + - static: + set: true + - connected: + set: true + advertise: + afi: l2vpn + safi: evpn - afi: ipv4 redistribute: - connected: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml index 293bbe67a..e22a90dc0 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_bgp_address_family/vars/main.yaml @@ -4,6 +4,13 @@ merged: commands: - router bgp 65000 + - address-family l2vpn evpn + - neighbor 198.51.100.1 activate + - neighbor 198.51.100.1 inherit peer-policy LEAF-EVPN-PEER-POLICY + - address-family ipv4 vrf green + - advertise l2vpn evpn + - redistribute connected + - redistribute static - address-family ipv4 multicast - default-metric 12 - distance bgp 10 10 100 @@ -24,6 +31,22 @@ merged: after: address_family: + - afi: l2vpn + safi: evpn + neighbor: + - address: 198.51.100.1 + activate: true + inherit: LEAF-EVPN-PEER-POLICY + - afi: ipv4 + vrf: green + advertise: + afi: l2vpn + safi: evpn + redistribute: + - static: + set: true + - connected: + set: true - afi: ipv4 redistribute: - connected: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml index 1578073cf..290765cbc 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_command/tests/cli/error_regex.yaml @@ -31,11 +31,6 @@ commands: - show logging - - name: Ensure task fails due to mismatched regex - ansible.builtin.assert: - that: - - result.failed == true - - name: Pause to avoid rate limiting-2 ansible.builtin.pause: seconds: 20 diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/acl_config.j2 b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/acl_config.j2 new file mode 100644 index 000000000..ec4ee46b7 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/templates/basic/acl_config.j2 @@ -0,0 +1,4 @@ +ip access-list extended test + permit ip host 192.0.2.1 any log + permit ip host 192.0.2.2 any log + permit ip host 192.0.2.3 any log diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/replace_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/replace_config.yaml new file mode 100644 index 000000000..18f62808f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_config/tests/cli/replace_config.yaml @@ -0,0 +1,28 @@ +--- +- ansible.builtin.debug: msg="START cli/replace_block.yaml on connection={{ ansible_connection }}" + +- name: "setup" + cisco.ios.ios_config: + lines: + - "no ip access-list extended test" + +- name: "Populate ios acls configuration with replace block and lines options" + register: result1 + cisco.ios.ios_config: + lines: "{{ lookup('template', 'basic/acl_config.j2') }}" + replace: block + +- ansible.builtin.assert: + that: + - result1.changed == true + +- name: "Populate acl configuration with replace block and src options" + register: result2 + cisco.ios.ios_config: + src: basic/acl_config.j2 + replace: block + +- ansible.builtin.assert: + that: + - result2.changed == true + - result1.commands == result2.commands diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/meta/main.yaml new file mode 100644 index 000000000..23d65c7ef --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tasks/cli.yaml index cd8c04990..6f505600c 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/cli.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tasks/cli.yaml @@ -3,16 +3,19 @@ ansible.builtin.find: paths: "{{ role_path }}/tests/cli" patterns: "{{ testcase }}.yaml" + use_regex: true register: test_cases delegate_to: localhost - name: Set test_items ansible.builtin.set_fact: test_items: "{{ test_cases.files | map(attribute='path') | list }}" + delegate_to: localhost -- name: Run test cases (connection=ansible.netcommon.network_cli) +- name: Run test case (connection=ansible.netcommon.network_cli) ansible.builtin.include_tasks: "{{ test_case_to_run }}" + vars: + ansible_connection: ansible.netcommon.network_cli with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run - tags: network_cli diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tasks/main.yaml new file mode 100644 index 000000000..39c4567e9 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Main task for EVPN EVI module + ansible.builtin.include_tasks: cli.yaml + tags: + - network_cli diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_parsed.cfg new file mode 100644 index 000000000..b2df4cb25 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_parsed.cfg @@ -0,0 +1,9 @@ +l2vpn evpn instance 101 vlan-based + encapsulation vxlan + replication-type ingress + default-gateway advertise enable +! +l2vpn evpn instance 102 vlan-based + encapsulation vxlan + replication-type ingress +! diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_populate_config.yaml new file mode 100644 index 000000000..07d1d93c3 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_populate_config.yaml @@ -0,0 +1,13 @@ +--- +- name: Populate configuration + cisco.ios.ios_evpn_evi: + config: + - evi: 101 + replication_type: static + - evi: 102 + replication_type: ingress + - evi: 201 + replication_type: static + - evi: 202 + replication_type: ingress + state: merged diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_remove_config.yaml new file mode 100644 index 000000000..b0892f314 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/_remove_config.yaml @@ -0,0 +1,15 @@ +--- +- name: Remove VLAN config + ansible.netcommon.cli_config: + config: | + no vlan configuration 101 + no vlan configuration 102 + no vlan configuration 201 + no vlan configuration 202 + no vlan configuration 901 + no vlan configuration 902 + +- name: Remove all configuration evpn_evi + cisco.ios.ios_evpn_evi: + config: + state: deleted diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/deleted.yaml new file mode 100644 index 000000000..4192f1844 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/deleted.yaml @@ -0,0 +1,32 @@ +--- +- ansible.builtin.debug: + msg: Start Deleted integration state for ios_evpn_evi ansible_connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Delete attributes of all configured EVPN EVI + register: result + cisco.ios.ios_evpn_evi: + config: + - evi: 101 + state: deleted + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - deleted['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - deleted['after'] == result['after'] + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/empty_config.yaml new file mode 100644 index 000000000..b5b7be66d --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/empty_config.yaml @@ -0,0 +1,58 @@ +--- +- ansible.builtin.debug: + msg: START ios_evpn_evi empty_config.yaml integration tests on connection={{ ansible_connection }} + +- name: Merged with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_evi: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_evi: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_evi: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_evi: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_evi: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/gathered.yaml new file mode 100644 index 000000000..553cb862f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/gathered.yaml @@ -0,0 +1,22 @@ +--- +- ansible.builtin.debug: + msg: START ios_evpn_evi gathered integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Ios_evpn_evi gather - play + register: result + cisco.ios.ios_evpn_evi: + config: + state: gathered + + - name: Ios_evpn_evi gather - assert + ansible.builtin.assert: + that: + - result.changed == false + - gathered['after'] == result['gathered'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/merged.yaml new file mode 100644 index 000000000..c4b485cce --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/merged.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: START Merged ios_evpn_evi state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Merge provided configuration with device configuration + register: result + cisco.ios.ios_evpn_evi: &id001 + config: + - evi: 101 + replication_type: ingress + route_distinguisher: "1:1" + default_gateway: + advertise: + enable: false + ip: + local_learning: + enable: true + - evi: 202 + replication_type: static + default_gateway: + advertise: + enable: true + ip: + local_learning: + disable: true + state: merged + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['after'] + + - name: Merge provided configuration with device configuration (idempotent) + register: result + cisco.ios.ios_evpn_evi: *id001 + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/overridden.yaml new file mode 100644 index 000000000..c33417f3e --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/overridden.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: START Overridden ios_evpn_evi state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Override device configuration of all EVPN EVI with provided configuration + register: result + cisco.ios.ios_evpn_evi: &id001 + config: + - evi: 101 + replication_type: ingress + default_gateway: + advertise: + enable: true + - evi: 202 + replication_type: static + default_gateway: + advertise: + enable: true + state: overridden + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - overridden['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - overridden['after'] == result['after'] + + - name: Override device configuration of all EVPN EVI with provided configuration (idempotent) + register: result + cisco.ios.ios_evpn_evi: *id001 + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/parsed.yaml new file mode 100644 index 000000000..fec21d532 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/parsed.yaml @@ -0,0 +1,19 @@ +--- +- ansible.builtin.debug: + msg: START Parsed ios_evpn_evi state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_evpn_evi parsed - play + register: result + cisco.ios.ios_evpn_evi: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + + - name: Ios_evpn_evi parsed - assert config + ansible.builtin.assert: + that: + - result.changed == false + - parsed['after'] == result['parsed'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/rendered.yaml new file mode 100644 index 000000000..8b2fd0dd9 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/rendered.yaml @@ -0,0 +1,23 @@ +--- +- ansible.builtin.debug: + msg: START Rendered ios_evpn_evi state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_evpn_evi rendered - play + register: result + cisco.ios.ios_evpn_evi: + config: + - evi: 101 + replication_type: ingress + default_gateway: + advertise: + enable: true + - evi: 202 + replication_type: ingress + state: rendered + + - name: Ios_evpn_evi rendered - assert commands + ansible.builtin.assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) | length == 0 }}" + - result['changed'] == false diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/replaced.yaml new file mode 100644 index 000000000..656cb23ef --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/tests/cli/replaced.yaml @@ -0,0 +1,46 @@ +--- +- ansible.builtin.debug: + msg: START Replaced ios_evpn_evi state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Replaces device configuration of listed EVPN EVI with provided configuration + register: result + cisco.ios.ios_evpn_evi: &id001 + config: + - evi: 101 + replication_type: ingress + default_gateway: + advertise: + enable: true + - evi: 202 + replication_type: ingress + state: replaced + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - replaced['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - replaced['after'] == result['after'] + + - name: Replaces device configuration of listed EVPN EVI with provided configuration (idempotent) + register: result + cisco.ios.ios_evpn_evi: *id001 + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/vars/main.yaml new file mode 100644 index 000000000..4818d9828 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_evi/vars/main.yaml @@ -0,0 +1,183 @@ +--- +merged: + before: + - evi: 101 + encapsulation: vxlan + replication_type: static + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + commands: + - l2vpn evpn instance 202 vlan-based + - default-gateway advertise enable + - ip local-learning disable + - replication-type static + - l2vpn evpn instance 101 vlan-based + - ip local-learning enable + - replication-type ingress + - rd 1:1 + after: + - evi: 101 + encapsulation: vxlan + replication_type: ingress + ip: + local_learning: + enable: true + route_distinguisher: "1:1" + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: static + ip: + local_learning: + disable: true + default_gateway: + advertise: + enable: true + +replaced: + before: + - evi: 101 + encapsulation: vxlan + replication_type: static + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + commands: + - l2vpn evpn instance 101 vlan-based + - replication-type ingress + - default-gateway advertise enable + after: + - evi: 101 + default_gateway: + advertise: + enable: true + encapsulation: vxlan + replication_type: ingress + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + +overridden: + before: + - evi: 101 + encapsulation: vxlan + replication_type: static + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + commands: + - no l2vpn evpn instance 102 vlan-based + - no l2vpn evpn instance 201 vlan-based + - l2vpn evpn instance 101 vlan-based + - default-gateway advertise enable + - replication-type ingress + - l2vpn evpn instance 202 vlan-based + - default-gateway advertise enable + - replication-type static + after: + - evi: 101 + encapsulation: vxlan + replication_type: ingress + default_gateway: + advertise: + enable: true + - evi: 202 + encapsulation: vxlan + replication_type: static + default_gateway: + advertise: + enable: true + +deleted: + before: + - evi: 101 + encapsulation: vxlan + replication_type: static + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + commands: + - no l2vpn evpn instance 101 vlan-based + after: + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + +rendered: + commands: + - l2vpn evpn instance 101 vlan-based + - default-gateway advertise enable + - encapsulation vxlan + - replication-type ingress + - l2vpn evpn instance 202 vlan-based + - encapsulation vxlan + - replication-type ingress + +gathered: + after: + - evi: 101 + encapsulation: vxlan + replication_type: static + - evi: 102 + encapsulation: vxlan + replication_type: ingress + - evi: 201 + encapsulation: vxlan + replication_type: static + - evi: 202 + encapsulation: vxlan + replication_type: ingress + +parsed: + after: + - evi: 101 + encapsulation: vxlan + replication_type: ingress + default_gateway: + advertise: + enable: true + - evi: 102 + encapsulation: vxlan + replication_type: ingress diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/meta/main.yaml new file mode 100644 index 000000000..23d65c7ef --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/cli.yaml new file mode 100644 index 000000000..6f505600c --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/cli.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect all CLI test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + delegate_to: localhost + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/main.yaml new file mode 100644 index 000000000..83b543a3f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Main task for evpn_global module + ansible.builtin.include_tasks: cli.yaml + tags: + - network_cli diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_parsed.cfg new file mode 100644 index 000000000..c43065fd2 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_parsed.cfg @@ -0,0 +1,5 @@ +l2vpn evpn + replication-type ingress + router-id Loopback1 + default-gateway advertise + route-target auto vni diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_populate_config.yaml new file mode 100644 index 000000000..89c6d4ee8 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_populate_config.yaml @@ -0,0 +1,19 @@ +--- +- name: Configure Loopback1 + vars: + lines: "interface Loopback 1\nip address 172.16.254.4 255.255.255.255\nip pim sparse-mode\n" + ansible.netcommon.cli_config: + config: "{{ lines }}" + +- name: Populate configuration evpn_global + cisco.ios.ios_evpn_global: + config: + replication_type: ingress + route_target: + auto: + vni: true + router_id: Loopback1 + ip: + local_learning: + disable: true + state: merged diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_remove_config.yaml new file mode 100644 index 000000000..8e07ea809 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/_remove_config.yaml @@ -0,0 +1,5 @@ +--- +- name: Remove all configuration evpn_global + cisco.ios.ios_evpn_global: + config: + state: deleted diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/deleted.yaml new file mode 100644 index 000000000..6ed823307 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/deleted.yaml @@ -0,0 +1,38 @@ +--- +- ansible.builtin.debug: + msg: Start Deleted integration state for ios_evpn_global ansible_connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Ios_evpn_global deleted - play + register: result + cisco.ios.ios_evpn_global: &id001 + config: + state: deleted + + - name: Ios_evpn_global deleted - assert commands + ansible.builtin.assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Ios_evpn_global deleted - assert before + ansible.builtin.assert: + that: + - deleted['before'] == result['before'] + + - name: Ios_evpn_global deleted - assert after + ansible.builtin.assert: + that: + - deleted['after'] == result['after'] + + - name: Ios_evpn_global deleted - play (idempotent) + register: result + cisco.ios.ios_evpn_global: *id001 + - name: Ios_evpn_global deleted - assert above task was idempotent + ansible.builtin.assert: + that: + - result.changed == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/empty_config.yaml new file mode 100644 index 000000000..8625feaa5 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/empty_config.yaml @@ -0,0 +1,25 @@ +--- +- ansible.builtin.debug: + msg: START ios_evpn_global empty_config.yaml integration tests on connection={{ ansible_connection }} + +- name: Merged with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_global: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_evpn_global: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/gathered.yaml new file mode 100644 index 000000000..51bf9bc3d --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/gathered.yaml @@ -0,0 +1,22 @@ +--- +- ansible.builtin.debug: + msg: START Gathered ios_evpn_global state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Ios_evpn_global gathered - play + register: result + cisco.ios.ios_evpn_global: + config: + state: gathered + + - name: Ios_evpn_global gathered - assert config + ansible.builtin.assert: + that: + - result.changed == false + - gathered['after'] == result['gathered'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/merged.yaml new file mode 100644 index 000000000..485c85778 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/merged.yaml @@ -0,0 +1,50 @@ +--- +- ansible.builtin.debug: + msg: START Merged ios_evpn_global state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml + +- block: + - name: Ios_evpn_global merged - play + register: result + cisco.ios.ios_evpn_global: &id001 + config: + router_id: Loopback1 + replication_type: ingress + route_target: + auto: + vni: true + default_gateway: + advertise: false + ip: + local_learning: + disable: true + flooding_suppression: + address_resolution: + disable: false + state: merged + + - name: Ios_evpn_global merged - assert commands + ansible.builtin.assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Ios_evpn_global merged - assert before + ansible.builtin.assert: + that: + - merged['before'] == result['before'] + + - name: Ios_evpn_global merged - assert after + ansible.builtin.assert: + that: + - merged['after'] == result['after'] + + - name: Ios_evpn_global merged - play (idempotent) + register: result + cisco.ios.ios_evpn_global: *id001 + - name: Ios_evpn_global merged - assert above task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/parsed.yaml new file mode 100644 index 000000000..2d582cab9 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/parsed.yaml @@ -0,0 +1,19 @@ +--- +- ansible.builtin.debug: + msg: START Parsed ios_evpn_global state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_evpn_global parsed - play + register: result + cisco.ios.ios_evpn_global: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + + - name: Ios_evpn_global parsed - assert config + ansible.builtin.assert: + that: + - result.changed == false + - parsed['after'] == result['parsed'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/rendered.yaml new file mode 100644 index 000000000..e1fb538d0 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/rendered.yaml @@ -0,0 +1,20 @@ +--- +- ansible.builtin.debug: + msg: START Rendered ios_evpn_global state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_evpn_global rendered - play + register: result + cisco.ios.ios_evpn_global: + config: + replication_type: static + route_target: + auto: + vni: true + state: rendered + + - name: Ios_evpn_global rendered - assert commands + ansible.builtin.assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) | length == 0 }}" + - result['changed'] == false diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/replaced.yaml new file mode 100644 index 000000000..47a9bb62f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/tests/cli/replaced.yaml @@ -0,0 +1,45 @@ +--- +- ansible.builtin.debug: + msg: START Replaced ios_evpn_global state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Ios_evpn_global replaced - play + register: result + cisco.ios.ios_evpn_global: &id001 + config: + replication_type: static + router_id: Loopback1 + default_gateway: + advertise: true + flooding_suppression: + address_resolution: + disable: true + state: replaced + + - name: Ios_evpn_global replaced - assert commands + ansible.builtin.assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Ios_evpn_global replaced - assert before + ansible.builtin.assert: + that: + - replaced['before'] == result['before'] + + - name: Ios_evpn_global replaced - assert after + ansible.builtin.assert: + that: + - replaced['after'] == result['after'] + + - name: Ios_evpn_global replaced - play (idempotent) + register: result + cisco.ios.ios_evpn_global: *id001 + - name: Ios_evpn_global replaced - assert above task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/vars/main.yaml new file mode 100644 index 000000000..7840aef0d --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_evpn_global/vars/main.yaml @@ -0,0 +1,85 @@ +--- +merged: + before: {} + commands: + - l2vpn evpn + - ip local-learning disable + - replication-type ingress + - route-target auto vni + - router-id Loopback1 + after: + replication_type: ingress + route_target: + auto: + vni: true + router_id: Loopback1 + ip: + local_learning: + disable: true + +replaced: + before: + router_id: Loopback1 + ip: + local_learning: + disable: true + replication_type: ingress + route_target: + auto: + vni: true + commands: + - l2vpn evpn + - default-gateway advertise + - flooding-suppression address-resolution disable + - no ip local-learning disable + - replication-type static + - no route-target auto vni + after: + default_gateway: + advertise: true + flooding_suppression: + address_resolution: + disable: true + replication_type: static + router_id: Loopback1 + +deleted: + before: + replication_type: ingress + route_target: + auto: + vni: true + router_id: Loopback1 + ip: + local_learning: + disable: true + commands: + - no l2vpn evpn + after: {} + +rendered: + commands: + - l2vpn evpn + - replication-type static + - route-target auto vni + +gathered: + after: + ip: + local_learning: + disable: true + replication_type: ingress + route_target: + auto: + vni: true + router_id: Loopback1 + +parsed: + after: + replication_type: ingress + route_target: + auto: + vni: true + router_id: Loopback1 + default_gateway: + advertise: true diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml index 1358a9ad2..ba8a1fd23 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_facts/tests/cli/all_facts.yaml @@ -1,13 +1,14 @@ --- - ansible.builtin.debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}" -- name: Test getting all facts +- name: Test fetching all facts register: result cisco.ios.ios_facts: gather_subset: - all -- ansible.builtin.assert: +- name: Assert output of all facts + ansible.builtin.assert: that: - result.changed == false - "'config' in result.ansible_facts.ansible_net_gather_subset" diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml deleted file mode 100644 index 5f709c5aa..000000000 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/defaults/main.yaml +++ /dev/null @@ -1,2 +0,0 @@ ---- -testcase: "*" diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml deleted file mode 100644 index ab3ad91bc..000000000 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/meta/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -dependencies: - - prepare_ios_tests diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml deleted file mode 100644 index 5e6448cf7..000000000 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tasks/main.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -- name: Main task for logging module - ansible.builtin.include_tasks: cli.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml deleted file mode 100644 index d14396195..000000000 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging/tests/cli/basic.yaml +++ /dev/null @@ -1,134 +0,0 @@ ---- -- name: Remove host logging - cisco.ios.ios_logging: &id001 - dest: host - name: 172.16.0.1 - state: absent - -- name: Remove console - cisco.ios.ios_logging: - dest: console - level: warnings - state: absent - -- name: Remove buffer - cisco.ios.ios_logging: - dest: buffered - size: 8000 - state: absent - -- name: Set up host logging - register: result - cisco.ios.ios_logging: - dest: host - name: 172.16.0.1 - facility: local7 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging host 172.16.0.1" in result.commands' - - '"logging facility local7" in result.commands' - -- name: Set up host logging again (idempotent) - register: result - cisco.ios.ios_logging: - dest: host - name: 172.16.0.1 - state: present - -- ansible.builtin.assert: &id002 - that: - - result.changed == false - -- name: Delete/disable host logging - register: result - cisco.ios.ios_logging: *id001 -- ansible.builtin.assert: - that: - - result.changed == true - - '"no logging host 172.16.0.1" in result.commands' - -- name: Delete/disable host logging (idempotent) - register: result - cisco.ios.ios_logging: *id001 -- ansible.builtin.assert: *id002 -- name: Console logging with level warnings - register: result - cisco.ios.ios_logging: - dest: console - level: warnings - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging console warnings" in result.commands' - -- name: Configure buffer size - register: result - cisco.ios.ios_logging: - dest: buffered - size: 8000 - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging buffered 8000" in result.commands' - -- name: Change logging parameters using aggregate - register: result - cisco.ios.ios_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 9000 - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging buffered 9000" in result.commands' - - '"logging console notifications" in result.commands' - -- name: Set both logging destination and facility - register: result - cisco.ios.ios_logging: &id003 - dest: buffered - facility: uucp - level: alerts - size: 4096 - state: present - -- ansible.builtin.assert: - that: - - result.changed == true - - '"logging buffered 4096 alerts" in result.commands' - - '"logging facility uucp" in result.commands' - -- name: Set both logging destination and facility (idempotent) - register: result - cisco.ios.ios_logging: *id003 -- ansible.builtin.assert: *id002 -- name: Remove logging as collection teardown - register: result - cisco.ios.ios_logging: - aggregate: - - dest: console - level: notifications - - - dest: buffered - size: 4096 - level: alerts - - - facility: uucp - state: absent - -- ansible.builtin.assert: - that: - - result.changed == true - - '"no logging console" in result.commands' - - '"no logging buffered" in result.commands' - - '"no logging facility uucp" in result.commands' diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml index c0690ed59..75cefbe36 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_logging_global/tests/cli/deleted.yaml @@ -1,6 +1,6 @@ --- - ansible.builtin.debug: - msg: Start Deleted integration state for ios_logging ansible_connection={{ ansible_connection }} + msg: Start Deleted integration state for ios_logging_global ansible_connection={{ ansible_connection }} - ansible.builtin.include_tasks: _remove_config.yaml - ansible.builtin.include_tasks: _populate_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml index 9c2298d9c..8439fa2f2 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_initial_vrf_setup.yaml @@ -1,6 +1,9 @@ --- - name: Create and setup VRF configuration - vars: - lines: "vrf definition ospf_vrf\naddress-family ipv4\nvrf definition blue\naddress-family ipv4\n" - ansible.netcommon.cli_config: - config: "{{ lines }}" + cisco.ios.ios_config: + lines: + - rd 100:1 + - route-target export 100:1 + - route-target import 100:1 + parents: + - ip vrf blue diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg index c3b4affb1..cbf17bf16 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/_parsed.cfg @@ -9,11 +9,10 @@ router ospf 1 default-information originate max-metric router-lsa on-startup 110 network 198.51.100.0 0.0.0.255 area 5 + area 5 capability default-exclusion area 10 authentication message-digest area 10 default-cost 10 area 10 nssa translate type7 suppress-fa area 10 nssa default-information-originate metric 10 area 10 filter-list prefix test_prefix_in in area 10 filter-list prefix test_prefix_out out - area 5 authentication - area 5 capability default-exclusion diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml index 439a1ff5f..27f07c04b 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/merged.yaml @@ -19,8 +19,6 @@ areas: - area_id: "5" capability: true - authentication: - enable: true - area_id: "10" authentication: message_digest: true diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml index b6c739efc..d045ef058 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/overridden.yaml @@ -30,12 +30,13 @@ authentication: message_digest: true - process_id: 100 - vrf: ospf_vrf + vrf: blue domain_id: ip_address: address: 192.0.5.1 auto_cost: reference_bandwidth: 5 + set: true areas: - area_id: "5" authentication: @@ -62,11 +63,12 @@ - "{{ overridden['after']['processes'] | symmetric_difference(result['after']['processes']) | length == 0 }}" - name: Override provided OSPF v2 configuration (idempotent) - register: result + register: result_id cisco.ios.ios_ospfv2: *id001 + - name: Assert that task was idempotent ansible.builtin.assert: that: - - result['changed'] == false + - result_id['changed'] == false always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml index b1bdade55..b2bff79a0 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/replaced.yaml @@ -30,12 +30,13 @@ authentication: message_digest: true - process_id: 100 - vrf: ospf_vrf + vrf: blue domain_id: ip_address: address: 192.0.5.1 auto_cost: reference_bandwidth: 5 + set: true areas: - area_id: "5" authentication: @@ -62,11 +63,12 @@ - "{{ replaced['after']['processes'] | symmetric_difference(result['after']['processes']) | length == 0 }}" - name: Replaced provided OSPF v2 configuration (idempotent) - register: result + register: result_id cisco.ios.ios_ospfv2: *id001 + - name: Assert that task was idempotent ansible.builtin.assert: that: - - result['changed'] == false + - result_id['changed'] == false always: - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml index b87da54b9..87a5694cb 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/tests/cli/rtt.yaml @@ -93,7 +93,7 @@ authentication: message_digest: true - process_id: 100 - vrf: ospf_vrf + vrf: blue domain_id: ip_address: address: 192.0.5.1 @@ -121,9 +121,14 @@ config: "{{ ansible_facts['network_resources']['ospfv2'] }}" state: overridden - - ansible.builtin.assert: + - name: Commands output + ansible.builtin.debug: + msg: "{{ revert }}" + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: that: - - revert.commands|length == 24 + - revert.commands|length == 23 - revert.changed == true - revert.commands|symmetric_difference(rtt.commands) == [] always: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml index 307b591e2..417cc5c9e 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ospfv2/vars/main.yaml @@ -20,15 +20,33 @@ merged: - area 10 nssa default-information-originate metric 10 - area 10 filter-list prefix test_prefix_out out - area 10 filter-list prefix test_prefix_in in - - area 5 authentication - area 5 capability default-exclusion after: processes: - areas: + - area_id: "10" + capability: true + auto_cost: + reference_bandwidth: 4 + set: true + distribute_list: + acls: + - direction: out + name: "10" + - direction: in + name: "123" + domain_id: + ip_address: + address: 192.0.3.1 + max_metric: + on_startup: + time: 100 + router_lsa: true + process_id: 200 + vrf: blue + - areas: - area_id: "5" - authentication: - enable: true capability: true - area_id: "10" authentication: @@ -54,30 +72,10 @@ merged: area: "5" wildcard_bits: 0.0.0.255 process_id: 1 - - areas: - - area_id: "10" - capability: true - auto_cost: - reference_bandwidth: 4 - distribute_list: - acls: - - direction: out - name: "10" - - direction: in - name: "123" - domain_id: - ip_address: - address: 192.0.3.1 - max_metric: - on_startup: - time: 100 - router_lsa: true - process_id: 200 - vrf: blue replaced: commands: - - router ospf 100 vrf ospf_vrf + - router ospf 100 vrf blue - auto-cost reference-bandwidth 5 - domain-id 192.0.5.1 - area 5 authentication message-digest @@ -98,9 +96,24 @@ replaced: after: processes: - areas: - - area_id: "5" + - area_id: "10" authentication: - enable: true + message_digest: true + default_cost: 10 + domain_id: + ip_address: + address: 192.0.4.1 + max_metric: + on_startup: + time: 200 + router_lsa: true + maximum_paths: 15 + process_id: 200 + ttl_security: + hops: 7 + vrf: blue + - areas: + - area_id: "5" capability: true - area_id: "10" authentication: @@ -136,33 +149,17 @@ replaced: translate: suppress-fa auto_cost: reference_bandwidth: 5 + set: true domain_id: ip_address: address: 192.0.5.1 process_id: 100 - vrf: ospf_vrf - - areas: - - area_id: "10" - authentication: - message_digest: true - default_cost: 10 - domain_id: - ip_address: - address: 192.0.4.1 - max_metric: - on_startup: - time: 200 - router_lsa: true - maximum_paths: 15 - process_id: 200 - ttl_security: - hops: 7 vrf: blue overridden: commands: - no router ospf 1 - - router ospf 100 vrf ospf_vrf + - router ospf 100 vrf blue - auto-cost reference-bandwidth 5 - domain-id 192.0.5.1 - area 5 authentication message-digest @@ -183,21 +180,6 @@ overridden: after: processes: - areas: - - area_id: "5" - authentication: - message_digest: true - nssa: - default_information_originate: - metric: 10 - translate: suppress-fa - auto_cost: - reference_bandwidth: 5 - domain_id: - ip_address: - address: 192.0.5.1 - process_id: 100 - vrf: ospf_vrf - - areas: - area_id: "10" authentication: message_digest: true @@ -214,6 +196,22 @@ overridden: ttl_security: hops: 7 vrf: blue + - areas: + - area_id: "5" + authentication: + message_digest: true + nssa: + default_information_originate: + metric: 10 + translate: suppress-fa + auto_cost: + reference_bandwidth: 5 + set: true + domain_id: + ip_address: + address: 192.0.5.1 + process_id: 100 + vrf: blue deleted: commands: @@ -224,7 +222,7 @@ deleted: rtt: commands: - - no router ospf 100 vrf ospf_vrf + - no router ospf 100 vrf blue - router ospf 200 vrf blue - auto-cost reference-bandwidth 4 - distribute-list 10 out @@ -246,5 +244,4 @@ rtt: - area 10 nssa default-information-originate metric 10 - area 10 filter-list prefix test_prefix_out out - area 10 filter-list prefix test_prefix_in in - - area 5 authentication - area 5 capability default-exclusion diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml index bc52e5ea8..71eda7ecb 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_ping/tests/cli/ping.yaml @@ -25,6 +25,12 @@ cisco.ios.ios_ping: dest: "{{ management_ip }}" +- name: Expected successful ping with size + register: esp + cisco.ios.ios_ping: + dest: "{{ management_ip }}" + size: 500 + - name: Unexpected unsuccessful ping register: uup ignore_errors: true diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml index 901bd9524..e0a1ffd6b 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/overridden.yaml @@ -12,35 +12,34 @@ config: - afi: ipv4 prefix_lists: - - name: 10 - description: this is override test + - description: this is override test entries: - action: deny - prefix: 12.0.0.0/8 ge: 15 + prefix: 12.0.0.0/8 sequence: 15 - action: deny - prefix: 14.0.0.0/8 ge: 20 le: 21 + prefix: 14.0.0.0/8 sequence: 20 - - name: test_override - description: this is override test + name: "10" + - description: this is override test entries: - action: deny - prefix: 35.0.0.0/8 ge: 20 + prefix: 35.0.0.0/8 sequence: 10 + name: test_override - afi: ipv6 prefix_lists: - - name: test_ipv6 - description: this is ipv6 override test - entries: + - entries: - action: deny - prefix: 2001:DB8:0:4::/64 ge: 80 le: 100 + prefix: 2001:DB8:0:4::/64 sequence: 10 + name: test_ipv6 state: overridden - name: Assert that correct set of commands were generated @@ -56,6 +55,7 @@ - name: Override provided prefix lists configuration (idempotent) register: result cisco.ios.ios_prefix_lists: *id001 + - name: Assert that task was idempotent ansible.builtin.assert: that: diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml index cbd519d9c..2ac0d2d71 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/tests/cli/replaced.yaml @@ -33,7 +33,6 @@ - afi: ipv6 prefix_lists: - name: test_ipv6 - description: this is ipv6 replace test entries: - action: deny prefix: 2001:DB8:0:4::/64 diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml index 78136adc0..c42ebac6c 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_prefix_lists/vars/main.yaml @@ -70,16 +70,16 @@ merged: overridden: commands: - - no ip prefix-list test - - no ip prefix-list test_prefix - ip prefix-list 10 description this is override test - - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10 - no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15 - - ip prefix-list test_override seq 10 deny 35.0.0.0/8 ge 20 + - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10 - ip prefix-list test_override description this is override test + - ip prefix-list test_override seq 10 deny 35.0.0.0/8 ge 20 + - no ip prefix-list test + - no ip prefix-list test_prefix + - no ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list - no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 - ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100 - - ipv6 prefix-list test_ipv6 description this is ipv6 override test after: - afi: ipv4 @@ -105,8 +105,7 @@ overridden: name: test_override - afi: ipv6 prefix_lists: - - description: this is ipv6 override test - entries: + - entries: - action: deny ge: 80 le: 100 @@ -117,13 +116,13 @@ overridden: replaced: commands: - ip prefix-list 10 description this is replace test - - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10 - no ip prefix-list 10 seq 5 deny 1.0.0.0/8 le 15 - - ip prefix-list test_replace seq 10 deny 35.0.0.0/8 ge 20 + - no ip prefix-list 10 seq 10 deny 35.0.0.0/8 ge 10 - ip prefix-list test_replace description this is replace test + - ip prefix-list test_replace seq 10 deny 35.0.0.0/8 ge 20 + - no ipv6 prefix-list test_ipv6 description this is ipv6 prefix-list - no ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 - ipv6 prefix-list test_ipv6 seq 10 deny 2001:DB8:0:4::/64 ge 80 le 100 - - ipv6 prefix-list test_ipv6 description this is ipv6 replace test after: - afi: ipv4 @@ -168,8 +167,7 @@ replaced: name: test_replace - afi: ipv6 prefix_lists: - - description: this is ipv6 replace test - entries: + - entries: - action: deny ge: 80 le: 100 diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml index 5d42f498e..3cb732e7f 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_user/tests/cli/auth.yaml @@ -37,6 +37,17 @@ ansible.builtin.assert: that: - results.failed + + - name: Test long password fails + cisco.ios.ios_user: + name: auth_user + privilege: 15 + role: network-operator + state: present + configured_password: "{{ 'a' * 128 }}" + register: result_fail + failed_when: "'Invalid Password length' not in result_fail.msg" + always: - name: Reset connection with {{ ansible_user }} ansible.builtin.meta: reset_connection diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed_vlan_config.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed_vlan_config.cfg new file mode 100644 index 000000000..0c81de124 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_parsed_vlan_config.cfg @@ -0,0 +1,12 @@ +vlan configuration 101 + member evpn-instance 101 vni 10101 +vlan configuration 102 + member evpn-instance 102 vni 10102 +vlan configuration 201 + member evpn-instance 201 vni 10201 +vlan configuration 202 + member evpn-instance 202 vni 10202 +vlan configuration 901 + member vni 50901 +vlan configuration 902 + member vni 50902 diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config_vlan_config.yaml new file mode 100644 index 000000000..d1c517a03 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_populate_config_vlan_config.yaml @@ -0,0 +1,17 @@ +--- +- name: Populate configuration + cisco.ios.ios_vlans: + config: + - vlan_id: 101 + member: + vni: 10101 + evi: 101 + - vlan_id: 102 + member: + vni: 10102 + evi: 102 + - vlan_id: 901 + member: + vni: 50901 + configuration: true + state: merged diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config_vlan_config.yaml new file mode 100644 index 000000000..f78bb0c56 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/_remove_config_vlan_config.yaml @@ -0,0 +1,12 @@ +--- +- name: Remove configuration + cisco.ios.ios_vlans: + config: + - vlan_id: 101 + - vlan_id: 102 + - vlan_id: 201 + - vlan_id: 202 + - vlan_id: 901 + - vlan_id: 902 + configuration: true + state: deleted diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted_vlan_config.yaml new file mode 100644 index 000000000..21249d763 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/deleted_vlan_config.yaml @@ -0,0 +1,39 @@ +--- +- ansible.builtin.debug: + msg: Start Deleted integration state for ios_vlans ansible_connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml + - ansible.builtin.include_tasks: _populate_config_vlan_config.yaml + +- block: + - name: Delete vlans attributes for all configured vlans + register: result + cisco.ios.ios_vlans: &id001 + configuration: true + state: deleted + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ deleted_vlan_config['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - deleted_vlan_config['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - deleted_vlan_config['after'] == result['after'] + + - name: Delete vlans attributes for all configured vlans (idempotent) + register: result + cisco.ios.ios_vlans: *id001 + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result.changed == false + always: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered_vlan_config.yaml new file mode 100644 index 000000000..576adee2f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/gathered_vlan_config.yaml @@ -0,0 +1,23 @@ +--- +- ansible.builtin.debug: + msg: START ios_vlans gathered integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml + - ansible.builtin.include_tasks: _populate_config_vlan_config.yaml + +- block: + - name: Gather the provided configuration with the existing running configuration + register: result + cisco.ios.ios_vlans: + config: + configuration: true + state: gathered + + - name: Assert + ansible.builtin.assert: + that: + - gathered_vlan_config.config == result.gathered + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged_vlan_config.yaml new file mode 100644 index 000000000..6efce0fc0 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/merged_vlan_config.yaml @@ -0,0 +1,46 @@ +--- +- ansible.builtin.debug: + msg: START Merged ios_vlans state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config_vlan_config.yaml +- ansible.builtin.include_tasks: _populate_config_vlan_config.yaml + +- block: + - name: Merge provided configuration with device configuration + register: result + cisco.ios.ios_vlans: &id001 + config: + - vlan_id: 201 + member: + vni: 10201 + evi: 201 + - vlan_id: 902 + member: + vni: 50902 + configuration: true + state: merged + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ merged_vlan_config['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged_vlan_config['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - merged_vlan_config['after'] == result['after'] + + - name: Merge provided configuration with device configuration (idempotent) + register: result + cisco.ios.ios_vlans: *id001 + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden_vlan_config.yaml new file mode 100644 index 000000000..52944e5ce --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/overridden_vlan_config.yaml @@ -0,0 +1,48 @@ +--- +- ansible.builtin.debug: + msg: START Overridden ios_vlans state for integration tests on connection={{ ansible_connection }} + +- block: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml + - ansible.builtin.include_tasks: _populate_config_vlan_config.yaml + +- block: + - name: Override device configuration of all vlans with provided configuration + register: result + cisco.ios.ios_vlans: &id001 + config: + - vlan_id: 101 + member: + vni: 10102 + evi: 102 + - vlan_id: 102 + member: + vni: 10101 + evi: 101 + configuration: true + state: overridden + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ overridden_vlan_config['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - overridden_vlan_config['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - overridden_vlan_config['after'] == result['after'] + + - name: Override device configuration of all interfaces with provided configuration (idempotent) + register: result + cisco.ios.ios_vlans: *id001 + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config_vlan_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed_vlan_config.yaml new file mode 100644 index 000000000..7d8311711 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/parsed_vlan_config.yaml @@ -0,0 +1,17 @@ +--- +- ansible.builtin.debug: + msg: START ios_vlans parsed integration tests on connection={{ ansible_connection }} + +- block: + - name: Parse the commands for provided configuration + become: true + register: result + cisco.ios.ios_vlans: + running_config: "{{ lookup('file', '_parsed_vlan_config.cfg') }}" + configuration: true + state: parsed + + - ansible.builtin.assert: + that: + - result.changed == false + - parsed_vlan_config.config == result.parsed diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered_vlan_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered_vlan_config.yaml new file mode 100644 index 000000000..63cc24a29 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/tests/cli/rendered_vlan_config.yaml @@ -0,0 +1,28 @@ +--- +- ansible.builtin.debug: + msg: Start ios_vlans rendered integration tests ansible_connection={{ ansible_connection }} + +- block: + - name: Render the commands for provided configuration + become: true + register: result + cisco.ios.ios_vlans: + config: + - vlan_id: 101 + member: + vni: 10101 + evi: 101 + - vlan_id: 102 + member: + vni: 10102 + evi: 102 + - vlan_id: 901 + member: + vni: 50901 + configuration: true + state: rendered + + - ansible.builtin.assert: + that: + - result.changed == false + - result.rendered|symmetric_difference(rendered_vlan_config.commands) == [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml index 72400621d..6092684a9 100644 --- a/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vlans/vars/main.yaml @@ -93,6 +93,43 @@ merged: shutdown: enabled state: active vlan_id: 1005 +merged_vlan_config: + before: + - vlan_id: 101 + member: + evi: 101 + vni: 10101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 901 + member: + vni: 50901 + commands: + - vlan configuration 201 + - member evpn-instance 201 vni 10201 + - vlan configuration 902 + - member vni 50902 + after: + - vlan_id: 101 + member: + evi: 101 + vni: 10101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 201 + member: + evi: 201 + vni: 10201 + - vlan_id: 901 + member: + vni: 50901 + - vlan_id: 902 + member: + vni: 50902 replaced: before: - mtu: 1500 @@ -278,6 +315,36 @@ overridden: shutdown: enabled state: active vlan_id: 1005 +overridden_vlan_config: + before: + - vlan_id: 101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 901 + member: + vni: 50901 + commands: + - vlan configuration 101 + - no member evpn-instance 101 vni 10101 + - vlan configuration 102 + - no member evpn-instance 102 vni 10102 + - vlan configuration 101 + - member evpn-instance 102 vni 10102 + - vlan configuration 102 + - member evpn-instance 101 vni 10101 + - no vlan configuration 901 + + after: + - vlan_id: 101 + member: + evi: 102 + vni: 10102 + - vlan_id: 102 + member: + evi: 101 + vni: 10101 deleted: before: - mtu: 1500 @@ -350,6 +417,26 @@ deleted: shutdown: enabled state: active vlan_id: 1005 +deleted_vlan_config: + before: + - vlan_id: 101 + member: + evi: 101 + vni: 10101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 901 + member: + vni: 50901 + commands: + - no vlan configuration 101 + - no vlan configuration 102 + - no vlan configuration 901 + + after: [] + gathered: config: - mtu: 1500 @@ -392,6 +479,21 @@ gathered: shutdown: enabled state: active vlan_id: 1005 + +gathered_vlan_config: + config: + - vlan_id: 101 + member: + evi: 101 + vni: 10101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 901 + member: + vni: 50901 + parsed: config: - mtu: 1500 @@ -435,6 +537,31 @@ parsed: state: active vlan_id: 1005 +parsed_vlan_config: + config: + - vlan_id: 101 + member: + evi: 101 + vni: 10101 + - vlan_id: 102 + member: + evi: 102 + vni: 10102 + - vlan_id: 201 + member: + evi: 201 + vni: 10201 + - vlan_id: 202 + member: + evi: 202 + vni: 10202 + - vlan_id: 901 + member: + vni: 50901 + - vlan_id: 902 + member: + vni: 50902 + rendered: commands: - vlan 10 @@ -452,6 +579,15 @@ rendered: - state suspend - shutdown +rendered_vlan_config: + commands: + - vlan configuration 101 + - member evpn-instance 101 vni 10101 + - vlan configuration 102 + - member evpn-instance 102 vni 10102 + - vlan configuration 901 + - member vni 50901 + rtt: commands: - vlan 10 diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/defaults/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/defaults/main.yaml new file mode 100644 index 000000000..164afead2 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/defaults/main.yaml @@ -0,0 +1,3 @@ +--- +testcase: "[^_].*" +test_items: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/meta/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/meta/main.yaml new file mode 100644 index 000000000..23d65c7ef --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/meta/main.yaml @@ -0,0 +1,2 @@ +--- +dependencies: [] diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/cli.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/cli.yaml new file mode 100644 index 000000000..6f505600c --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/cli.yaml @@ -0,0 +1,21 @@ +--- +- name: Collect all CLI test cases + ansible.builtin.find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + use_regex: true + register: test_cases + delegate_to: localhost + +- name: Set test_items + ansible.builtin.set_fact: + test_items: "{{ test_cases.files | map(attribute='path') | list }}" + delegate_to: localhost + +- name: Run test case (connection=ansible.netcommon.network_cli) + ansible.builtin.include_tasks: "{{ test_case_to_run }}" + vars: + ansible_connection: ansible.netcommon.network_cli + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/main.yaml new file mode 100644 index 000000000..d80ee1ae2 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tasks/main.yaml @@ -0,0 +1,5 @@ +--- +- name: Main task for VXLAN VTEP module + ansible.builtin.include_tasks: cli.yaml + tags: + - network_cli diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_parsed.cfg b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_parsed.cfg new file mode 100644 index 000000000..46ecf2e1d --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_parsed.cfg @@ -0,0 +1,7 @@ +interface nve1 + source-interface Loopback1 + host-reachability protocol bgp + member vni 10101 ingress-replication + member vni 10201 mcast-group 225.0.0.101 FF0E:225::101 + member vni 50901 vrf green + member vni 50902 vrf blue diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_config.yaml new file mode 100644 index 000000000..1587cb9bc --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_config.yaml @@ -0,0 +1,34 @@ +--- +- name: Populate VXLAN VTEP configuration + cisco.ios.ios_vxlan_vtep: + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + state: merged diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_vlan_vrf_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_vlan_vrf_config.yaml new file mode 100644 index 000000000..c6d5dee3e --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_populate_vlan_vrf_config.yaml @@ -0,0 +1,61 @@ +--- +- name: Configure VLANs and VRFs + ansible.netcommon.cli_config: + config: | + vlan 101 + name Access_VLAN_101 + vlan 102 + name Access_VLAN_102 + vlan 201 + name Access_VLAN_201 + vlan 202 + name Access_VLAN_202 + vlan 901 + name Core_VLAN_VRF_green + vlan 902 + name Core_VLAN_VRF_blue + vlan configuration 101 + member evpn-instance 101 vni 10101 + vlan configuration 102 + member evpn-instance 102 vni 10102 + vlan configuration 201 + member evpn-instance 201 vni 10201 + vlan configuration 202 + member evpn-instance 202 vni 10202 + vlan configuration 901 + member vni 50901 + vlan configuration 902 + member vni 50902 + vrf definition blue + description blue VRF defn + rd 2:2 + ! + address-family ipv4 + route-target export 2:2 + route-target import 2:2 + route-target export 2:2 stitching + route-target import 2:2 stitching + exit-address-family + ! + address-family ipv6 + route-target export 2:2 + route-target import 2:2 + route-target import 2:2 stitching + exit-address-family + vrf definition green + description green VRF defn + rd 1:1 + ! + address-family ipv4 + route-target export 1:1 + route-target import 1:1 + route-target export 1:1 stitching + route-target import 1:1 stitching + exit-address-family + ! + address-family ipv6 + route-target export 1:1 + route-target import 1:1 + route-target export 1:1 stitching + route-target import 1:1 stitching + exit-address-family diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_remove_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_remove_config.yaml new file mode 100644 index 000000000..52c43242f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/_remove_config.yaml @@ -0,0 +1,6 @@ +--- +- name: Remove VXLAN VTEP configuration + cisco.ios.ios_vxlan_vtep: + config: + - interface: nve1 + state: deleted diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/deleted.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/deleted.yaml new file mode 100644 index 000000000..75d18ddec --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/deleted.yaml @@ -0,0 +1,33 @@ +--- +- ansible.builtin.debug: + msg: Start Deleted integration state for ios_vxlan_vtep ansible_connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_vlan_vrf_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Delete provided VXLAN VTEP interface + register: result + cisco.ios.ios_vxlan_vtep: &id001 + config: + - interface: nve1 + state: deleted + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ deleted['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - "{{ merged['after'] | symmetric_difference(result['before']) | length == 0 }}" + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - "{{ deleted['after'] | symmetric_difference(result['after']) | length == 0 }}" + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/empty_config.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/empty_config.yaml new file mode 100644 index 000000000..4034115e5 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/empty_config.yaml @@ -0,0 +1,58 @@ +--- +- ansible.builtin.debug: + msg: START ios_vxlan_vtep empty_config.yaml integration tests on connection={{ ansible_connection }} + +- name: Merged with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_vxlan_vtep: + config: + state: merged + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state merged' + +- name: Replaced with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_vxlan_vtep: + config: + state: replaced + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state replaced' + +- name: Overridden with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_vxlan_vtep: + config: + state: overridden + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state overridden' + +- name: Rendered with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_vxlan_vtep: + config: + state: rendered + +- ansible.builtin.assert: + that: + - result.msg == 'value of config parameter must not be empty for state rendered' + +- name: Parsed with empty configuration should give appropriate error message + register: result + ignore_errors: true + cisco.ios.ios_vxlan_vtep: + running_config: + state: parsed + +- ansible.builtin.assert: + that: + - result.msg == 'value of running_config parameter must not be empty for state parsed' diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/gathered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/gathered.yaml new file mode 100644 index 000000000..2f334a79f --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/gathered.yaml @@ -0,0 +1,23 @@ +--- +- ansible.builtin.debug: + msg: START ios_vxlan_vtep gathered integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_vlan_vrf_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Ios_vxlan_vtep gather - play + register: result + cisco.ios.ios_vxlan_vtep: + config: + state: gathered + + - name: Ios_vxlan_vtep gather - assert + ansible.builtin.assert: + that: + - result.changed == false + - gathered['config'] == result['gathered'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/merged.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/merged.yaml new file mode 100644 index 000000000..ba004e9db --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/merged.yaml @@ -0,0 +1,67 @@ +--- +- ansible.builtin.debug: + msg: START Merged ios_vxlan_vtep state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_vlan_vrf_config.yaml + +- block: + - name: Merge provided configuration with device configuration + register: result + cisco.ios.ios_vxlan_vtep: &id001 + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + state: merged + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ merged['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - merged['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - merged['after'] == result['after'] + + - name: Merge provided configuration with device configuration (idempotent) + register: result + cisco.ios.ios_vxlan_vtep: *id001 + - name: Assert that the previous task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/overridden.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/overridden.yaml new file mode 100644 index 000000000..187d71eae --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/overridden.yaml @@ -0,0 +1,59 @@ +--- +- ansible.builtin.debug: + msg: START Overridden ios_vxlan_vtep state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_vlan_vrf_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Override device configuration of all VTEP interfaces with provided configuration + register: result + cisco.ios.ios_vxlan_vtep: &id001 + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: static + mcast_group: + ipv6: FF0E:225::101 + - vni: 10201 + replication: + type: static + mcast_group: + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: blue + state: overridden + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ overridden['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - overridden['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - overridden['after'] == result['after'] + + - name: Override device configuration of all VTEP interfaces with provided configuration (idempotent) + register: result + cisco.ios.ios_vxlan_vtep: *id001 + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/parsed.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/parsed.yaml new file mode 100644 index 000000000..82d84b037 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/parsed.yaml @@ -0,0 +1,19 @@ +--- +- ansible.builtin.debug: + msg: START Parsed ios_vxlan_vtep state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_vxlan_vtep parsed - play + register: result + cisco.ios.ios_vxlan_vtep: + running_config: "{{ lookup('file', '_parsed.cfg') }}" + state: parsed + + - name: Ios_vxlan_vtep parsed - assert config + ansible.builtin.assert: + that: + - result.changed == false + - parsed['config'] == result['parsed'] + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/rendered.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/rendered.yaml new file mode 100644 index 000000000..9979d6f30 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/rendered.yaml @@ -0,0 +1,34 @@ +--- +- ansible.builtin.debug: + msg: START Rendered ios_vxlan_vtep state for integration tests on connection={{ ansible_connection }} + +- block: + - name: Ios_vxlan_vtep rendered - play + register: result + cisco.ios.ios_vxlan_vtep: &id001 + config: + - interface: nve1 + source_interface: Loopback1 + member: + vni: + l2vni: + - vni: 10101 + replication: + type: static + mcast_group: + ipv6: FF0E:225::101 + - vni: 10201 + replication: + type: static + mcast_group: + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: blue + state: rendered + + - name: Ios_vxlan_vtep rendered - assert commands + ansible.builtin.assert: + that: + - "{{ rendered['commands'] | symmetric_difference(result['rendered']) | length == 0 }}" + - result['changed'] == false diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/replaced.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/replaced.yaml new file mode 100644 index 000000000..5e24f4336 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/tests/cli/replaced.yaml @@ -0,0 +1,56 @@ +--- +- ansible.builtin.debug: + msg: START Replaced ios_vxlan_vtep state for integration tests on connection={{ ansible_connection }} + +- ansible.builtin.include_tasks: _remove_config.yaml +- ansible.builtin.include_tasks: _populate_vlan_vrf_config.yaml +- ansible.builtin.include_tasks: _populate_config.yaml + +- block: + - name: Replaces device configuration of listed VTEP interfaces with provided configuration + register: result + cisco.ios.ios_vxlan_vtep: &id001 + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: static + mcast_group: + ipv6: FF0E:225::101 + - vni: 10201 + replication: + type: static + mcast_group: + ipv6: FF0E:225::102 + state: replaced + + - name: Assert that correct set of commands were generated + ansible.builtin.assert: + that: + - "{{ replaced['commands'] | symmetric_difference(result['commands']) | length == 0 }}" + + - name: Assert that before dicts are correctly generated + ansible.builtin.assert: + that: + - replaced['before'] == result['before'] + + - name: Assert that after dict is correctly generated + ansible.builtin.assert: + that: + - replaced['after'] == result['after'] + + - name: Replaces device configuration of listed VTEP interfaces with provided configuration (idempotent) + register: result + cisco.ios.ios_vxlan_vtep: *id001 + - name: Assert that task was idempotent + ansible.builtin.assert: + that: + - result['changed'] == false + + always: + - ansible.builtin.include_tasks: _remove_config.yaml diff --git a/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/vars/main.yaml b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/vars/main.yaml new file mode 100644 index 000000000..9ee70d3f7 --- /dev/null +++ b/ansible_collections/cisco/ios/tests/integration/targets/ios_vxlan_vtep/vars/main.yaml @@ -0,0 +1,274 @@ +--- +merged: + before: + - interface: nve1 + commands: + - interface nve1 + - source-interface Loopback1 + - host-reachability protocol bgp + - member vni 10101 ingress-replication + - member vni 10102 ingress-replication + - member vni 10201 mcast-group 225.0.0.101 FF0E:225::101 + - member vni 10202 mcast-group 225.0.0.102 FF0E:225::102 + - member vni 50901 vrf green + - member vni 50902 vrf blue + after: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue +replaced: + before: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + commands: + - interface nve1 + - no member vni 10101 ingress-replication + - member vni 10101 mcast-group FF0E:225::101 + - no member vni 10201 mcast-group 225.0.0.101 FF0E:225::101 + - member vni 10201 mcast-group FF0E:225::102 + - no member vni 10102 ingress-replication + - no member vni 10202 mcast-group 225.0.0.102 FF0E:225::102 + - no member vni 50901 vrf green + - no member vni 50902 vrf blue + after: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: static + mcast_group: + ipv6: FF0E:225::101 + - vni: 10201 + replication: + type: static + mcast_group: + ipv6: FF0E:225::102 + +overridden: + before: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + commands: + - interface nve1 + - no member vni 10101 ingress-replication + - member vni 10101 mcast-group FF0E:225::101 + - no member vni 10201 mcast-group 225.0.0.101 FF0E:225::101 + - member vni 10201 mcast-group FF0E:225::102 + - no member vni 10102 ingress-replication + - no member vni 10202 mcast-group 225.0.0.102 FF0E:225::102 + - no member vni 50901 vrf green + - no member vni 50902 vrf blue + - member vni 50901 vrf blue + after: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: static + mcast_group: + ipv6: FF0E:225::101 + - vni: 10201 + replication: + type: static + mcast_group: + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: blue + +deleted: + before: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + commands: + - interface nve1 + - no source-interface Loopback1 + - no host-reachability protocol bgp + - no member vni 10101 ingress-replication + - no member vni 10102 ingress-replication + - no member vni 10201 mcast-group 225.0.0.101 FF0E:225::101 + - no member vni 10202 mcast-group 225.0.0.102 FF0E:225::102 + - no member vni 50901 vrf green + - no member vni 50902 vrf blue + + after: + - interface: nve1 + host_reachability_bgp: true + +gathered: + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10102 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + - vni: 10202 + replication: + type: static + mcast_group: + ipv4: 225.0.0.102 + ipv6: FF0E:225::102 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + +parsed: + config: + - interface: nve1 + source_interface: Loopback1 + host_reachability_bgp: true + member: + vni: + l2vni: + - vni: 10101 + replication: + type: ingress + - vni: 10201 + replication: + type: static + mcast_group: + ipv4: 225.0.0.101 + ipv6: FF0E:225::101 + l3vni: + - vni: 50901 + vrf: green + - vni: 50902 + vrf: blue + +rendered: + commands: + - interface nve1 + - source-interface Loopback1 + - member vni 10101 mcast-group FF0E:225::101 + - member vni 10201 mcast-group FF0E:225::102 + - member vni 50901 vrf blue |