--- - debug: msg="START cnos_l3_interface cli/basic.yaml on connection={{ ansible_connection }}" - name: Delete interface ipv4 and ipv6 address(setup) cnos_l3_interface: name: "{{ test_interface }}" state: absent provider: "{{ cli }}" register: result - name: Delete interface ipv4 and ipv6 address 2 (setup) cnos_l3_interface: name: "{{ test_interface2 }}" state: absent provider: "{{ cli }}" register: result - name: Setup - Ensure interfaces are switchport cnos_config: lines: - no shutdown parents: - "interface {{ item }}" provider: "{{ cli }}" loop: - "{{ test_interface }}" - "{{ test_interface2 }}" - name: Configure interface ipv4 address cnos_l3_interface: name: "{{ test_interface }}" ipv4: 10.241.113.1/24 state: present provider: "{{ cli }}" register: result - assert: that: - 'result.changed == true' - '"interface {{ test_interface }}" in result.commands' - '"ip address 10.241.113.1 255.255.255.0" in result.commands' - name: Configure interface ipv4 address (idempotent) cnos_l3_interface: name: "{{ test_interface }}" ipv4: 10.241.113.1/24 state: present provider: "{{ cli }}" register: result - assert: &unchanged that: - 'result.changed == false' - name: Assign same ipv4 address to other interface (fail) cnos_l3_interface: name: "{{ test_interface2 }}" ipv4: 10.241.113.1/24 state: present provider: "{{ cli }}" ignore_errors: yes register: result - assert: that: - "result.failed == true" - "result.msg is defined" - name: Change interface ipv4 address cnos_l3_interface: name: "{{ test_interface }}" ipv4: dhcp state: present provider: "{{ cli }}" register: result - assert: that: - 'result.changed == true' - '"interface {{ test_interface }}" in result.commands' - '"ip address dhcp" in result.commands' - name: Configure interface ipv6 address cnos_l3_interface: &ipv6-1 name: "{{ test_interface }}" ipv6: fd5d:12c9:2201:1::1/64 state: present provider: "{{ cli }}" 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) cnos_l3_interface: *ipv6-1 register: result - assert: that: - 'result.changed == false' - name: Configure second ipv6 address on interface cnos_l3_interface: &ipv6-2 name: "{{ test_interface }}" ipv6: fd5d:12c9:2291:1::1/64 state: present provider: "{{ cli }}" register: result - assert: that: - '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 cnos_l3_interface: *ipv6-1 register: result - assert: that: - 'result.changed == true' - name: Ensure second ipv6 address still associated with interface cnos_l3_interface: *ipv6-2 register: result - assert: that: - 'result.changed == true' - name: Assign same ipv6 address to other interface (fail) cnos_l3_interface: name: "{{ test_interface2 }}" ipv6: fd5d:12c9:2201:1::1/64 state: present provider: "{{ cli }}" ignore_errors: yes register: result - assert: that: - 'result.changed == true' - '"interface {{ test_interface2 }}" in result.commands' - '"ipv6 address fd5d:12c9:2201:1::1/64" in result.commands' - name: Change interface ipv6 address cnos_l3_interface: name: "{{ test_interface }}" ipv6: dhcp state: present provider: "{{ cli }}" 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 cnos_l3_interface: name: "{{ test_interface }}" state: absent provider: "{{ cli }}" 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) cnos_l3_interface: name: "{{ test_interface }}" state: absent provider: "{{ cli }}" register: result - assert: that: - 'result.changed == false' - name: Delete second interface ipv4 and ipv6 address (setup) cnos_l3_interface: name: "{{ test_interface2 }}" state: absent provider: "{{ cli }}" register: result - name: Configure ipv4 and ipv6 address using aggregate cnos_l3_interface: aggregate: - { name: "{{ test_interface }}", ipv4: 10.241.113.1/24, ipv6: "fd5d:12c9:2201:2::2/64" } - { name: "{{ test_interface2 }}", ipv4: 10.141.233.2/16, ipv6: "fd5e:12c9:2201:3::3/32" } provider: "{{ cli }}" register: result - assert: that: - 'result.changed == true' - '"interface {{ test_interface }}" in result.commands' - '"ip address 10.241.113.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 10.141.233.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) cnos_l3_interface: aggregate: - { name: "{{ test_interface }}", ipv4: 10.241.113.1/24, ipv6: "fd5d:12c9:2201:2::2/64" } - { name: "{{ test_interface2 }}", ipv4: 10.141.233.2/16, ipv6: "fd5e:12c9:2201:3::3/32" } provider: "{{ cli }}" register: result - assert: that: - 'result.changed == false' - name: Change ipv4 and ipv6 address using aggregate cnos_l3_interface: aggregate: - { name: "{{ test_interface }}", ipv4: 10.241.113.1/16, ipv6: "fd5a:12c9:2201:4::4/32" } - { name: "{{ test_interface2 }}", ipv4: 10.141.233.2/24, ipv6: "fd5b:12c9:2201:5::5/90" } provider: "{{ cli }}" register: result - assert: that: - 'result.changed == true' - '"interface {{ test_interface }}" in result.commands' - '"ip address 10.241.113.1 255.255.0.0" in result.commands' - '"ipv6 address fd5a:12c9:2201:4::4/32" in result.commands' - '"interface {{ test_interface2 }}" in result.commands' - '"ip address 10.141.233.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 cnos_l3_interface: aggregate: - { name: "{{ test_interface }}" } - { name: "{{ test_interface2 }}" } state: absent provider: "{{ cli }}" 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) cnos_l3_interface: aggregate: - { name: "{{ test_interface }}" } - { name: "{{ test_interface2 }}" } state: absent provider: "{{ cli }}" register: result - assert: that: - 'result.changed == false' - debug: msg="END cnos_l3_interface cli/basic.yaml on connection={{ ansible_connection }}"