1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/targets/ios_l3_interface/tests/cli/basic.yaml
Ganesh Nalawade d5061aa8e6
Add ios_l3_interface module (#34201)
* Add ios_l3_interface module

Fixes #31298

*  Add ios_3_interface module
*  Integration test
*  Return command response for load_config()

* Fix CI issues
2017-12-23 11:24:00 +05:30

261 lines
7.3 KiB
YAML

---
- debug: msg="START ios_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"
- name: Run show version
ios_command:
commands: show version
authorize: yes
register: show_version_result
- block:
- name: Set test interface to GigabitEthernet0/1 as we are on Cisco IOS
set_fact: test_interface=GigabitEthernet0/1
- name: Set test interface 2 to GigabitEthernet0/2 as we are on Cisco IOS
set_fact: test_interface2=GigabitEthernet0/2
when: "'Cisco IOS' in show_version_result.stdout[0]"
- block:
- name: Set test interface to GigabitEthernet2 as we are on Cisco IOS-XE
set_fact: test_interface=GigabitEthernet2
- name: Disable autonegotiation on GigabitEthernet2
ios_config:
lines:
- no negotiation auto
parents: int GigabitEthernet2
authorize: yes
- name: Set test interface 2 to GigabitEthernet3 as we are on Cisco IOS-XE
set_fact: test_interface2=GigabitEthernet3
- name: Disable autonegotiation on GigabitEthernet3
ios_config:
lines:
- no negotiation auto
parents: int GigabitEthernet3
authorize: yes
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
- name: Delete interface ipv4 and ipv6 address(setup)
ios_l3_interface:
name: "{{ test_interface }}"
state: absent
authorize: yes
register: result
- name: Configure interface ipv4 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/24
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 192.168.0.1 255.255.255.0" in result.commands'
- name: Configure interface ipv4 address (idempotent)
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: 192.168.0.1/24
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == false'
- name: Assign same ipv4 address to other interface (fail)
ios_l3_interface:
name: "{{ test_interface2 }}"
ipv4: 192.168.0.1/24
state: present
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- name: Change interface ipv4 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv4: dhcp
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address dhcp" in result.commands'
- name: Configure interface ipv6 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ipv6 address fd5d:12c9:2201:1::1/64" in result.commands'
- name: Configure interface ipv6 address (idempotent)
ios_l3_interface:
name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == false'
- name: Assign same ipv6 address to other interface (fail)
ios_l3_interface:
name: "{{ test_interface2 }}"
ipv6: fd5d:12c9:2201:1::1/64
state: present
authorize: yes
ignore_errors: yes
register: result
- assert:
that:
- "result.failed == true"
- "result.msg is defined"
- name: Change interface ipv6 address
ios_l3_interface:
name: "{{ test_interface }}"
ipv6: dhcp
state: present
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ipv6 address dhcp" in result.commands'
- name: Delete interface ipv4 and ipv6 address
ios_l3_interface:
name: "{{ test_interface }}"
state: absent
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"no ip address" in result.commands'
- '"no ipv6 address" in result.commands'
- name: Delete interface ipv4 and ipv6 address (idempotent)
ios_l3_interface:
name: "{{ test_interface }}"
state: absent
authorize: yes
register: result
- name: Delete second interface ipv4 and ipv6 address (setup)
ios_l3_interface:
name: "{{ test_interface2 }}"
state: absent
authorize: yes
register: result
- name: Configure ipv4 and ipv6 address using aggregate
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" }
- { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" }
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 192.161.0.1 255.255.255.0" in result.commands'
- '"ipv6 address fd5d:12c9:2201:2::2/64" in result.commands'
- '"interface {{ test_interface2 }}" in result.commands'
- '"ip address 192.162.0.2 255.255.0.0" in result.commands'
- '"ipv6 address fd5e:12c9:2201:3::3/32" in result.commands'
- name: Configure ipv4 and ipv6 address using aggregate (idempotent)
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" }
- { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" }
authorize: yes
register: result
- assert:
that:
- 'result.changed == false'
- name: Change ipv4 and ipv6 address using aggregate
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}", ipv4: 193.167.1.1/8, ipv6: "fd5a:12c9:2201:4::4/32" }
- { name: "{{ test_interface2 }}", ipv4: 192.169.2.2/24, ipv6: "fd5b:12c9:2201:5::5/90" }
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"ip address 193.167.1.1 255.0.0.0" in result.commands'
- '"ipv6 address fd5a:12c9:2201:4::4/32" in result.commands'
- '"interface {{ test_interface2 }}" in result.commands'
- '"ip address 192.169.2.2 255.255.255.0" in result.commands'
- '"ipv6 address fd5b:12c9:2201:5::5/90" in result.commands'
- name: Delete ipv4 and ipv6 address using aggregate
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}" }
- { name: "{{ test_interface2 }}" }
state: absent
authorize: yes
register: result
- assert:
that:
- 'result.changed == true'
- '"interface {{ test_interface }}" in result.commands'
- '"no ip address" in result.commands'
- '"no ipv6 address" in result.commands'
- '"interface {{ test_interface2 }}" in result.commands'
- '"no ip address" in result.commands'
- '"no ipv6 address" in result.commands'
- name: Delete ipv4 and ipv6 address using aggregate (idempotent)
ios_l3_interface:
aggregate:
- { name: "{{ test_interface }}" }
- { name: "{{ test_interface2 }}" }
state: absent
authorize: yes
register: result
- assert:
that:
- 'result.changed == false'
- debug: msg="END ios_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"