2017-12-23 06:54:00 +01:00
|
|
|
---
|
|
|
|
- debug: msg="START ios_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
|
|
|
- name: Delete interface ipv4 and ipv6 address(setup)
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface }}"
|
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
2018-01-25 07:56:17 +01:00
|
|
|
- name: Setup - Ensure interfaces are switchport
|
|
|
|
ios_config:
|
|
|
|
lines:
|
|
|
|
- no shutdown
|
|
|
|
parents:
|
|
|
|
- "interface {{ item }}"
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2018-01-25 07:56:17 +01:00
|
|
|
loop:
|
|
|
|
- "{{ test_interface }}"
|
|
|
|
- "{{ test_interface2 }}"
|
|
|
|
|
2017-12-23 06:54:00 +01:00
|
|
|
- name: Configure interface ipv4 address
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface }}"
|
2018-05-21 23:51:21 +02:00
|
|
|
ipv4: 192.168.20.1/24
|
2017-12-23 06:54:00 +01:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"interface {{ test_interface }}" in result.commands'
|
2018-05-21 23:51:21 +02:00
|
|
|
- '"ip address 192.168.20.1 255.255.255.0" in result.commands'
|
2017-12-23 06:54:00 +01:00
|
|
|
|
|
|
|
- name: Configure interface ipv4 address (idempotent)
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface }}"
|
2018-05-21 23:51:21 +02:00
|
|
|
ipv4: 192.168.20.1/24
|
2017-12-23 06:54:00 +01:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
2018-05-22 18:00:16 +02:00
|
|
|
- assert: &unchanged
|
2017-12-23 06:54:00 +01:00
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
|
|
|
|
- name: Assign same ipv4 address to other interface (fail)
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface2 }}"
|
2018-05-21 23:51:21 +02:00
|
|
|
ipv4: 192.168.20.1/24
|
2017-12-23 06:54:00 +01:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"interface {{ test_interface }}" in result.commands'
|
|
|
|
- '"ip address dhcp" in result.commands'
|
|
|
|
|
|
|
|
- name: Configure interface ipv6 address
|
2018-05-22 18:00:16 +02:00
|
|
|
ios_l3_interface: &ipv6-1
|
2017-12-23 06:54:00 +01:00
|
|
|
name: "{{ test_interface }}"
|
|
|
|
ipv6: fd5d:12c9:2201:1::1/64
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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)
|
2018-05-22 18:00:16 +02:00
|
|
|
ios_l3_interface: *ipv6-1
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *unchanged
|
|
|
|
|
|
|
|
- name: Configure second ipv6 address on interface
|
|
|
|
ios_l3_interface: &ipv6-2
|
2017-12-23 06:54:00 +01:00
|
|
|
name: "{{ test_interface }}"
|
2018-05-22 18:00:16 +02:00
|
|
|
ipv6: fd5d:12c9:2291:1::1/64
|
2017-12-23 06:54:00 +01:00
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
2018-05-22 18:00:16 +02:00
|
|
|
- 'result.changed == true'
|
|
|
|
- '"interface {{ test_interface }}" in result.commands'
|
|
|
|
- '"ipv6 address fd5d:12c9:2291:1::1/64" in result.commands'
|
|
|
|
|
|
|
|
- name: Ensure first ipv6 address still associated with interface
|
|
|
|
ios_l3_interface: *ipv6-1
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *unchanged
|
|
|
|
|
|
|
|
- name: Ensure second ipv6 address still associated with interface
|
|
|
|
ios_l3_interface: *ipv6-2
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert: *unchanged
|
2017-12-23 06:54:00 +01:00
|
|
|
|
|
|
|
- name: Assign same ipv6 address to other interface (fail)
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface2 }}"
|
|
|
|
ipv6: fd5d:12c9:2201:1::1/64
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- name: Delete second interface ipv4 and ipv6 address (setup)
|
|
|
|
ios_l3_interface:
|
|
|
|
name: "{{ test_interface2 }}"
|
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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" }
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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" }
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
2018-05-22 18:00:16 +02:00
|
|
|
- assert: *unchanged
|
2017-12-23 06:54:00 +01:00
|
|
|
|
|
|
|
- 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" }
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
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
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-12-23 06:54:00 +01:00
|
|
|
register: result
|
|
|
|
|
2018-05-22 18:00:16 +02:00
|
|
|
- assert: *unchanged
|
2017-12-23 06:54:00 +01:00
|
|
|
|
|
|
|
- debug: msg="END ios_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"
|