---
- include_tasks: reset_config.yml

- set_fact:
    config:
      - name: Ethernet1
        ipv4:
          - address: 198.51.100.14/24
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.227/31

- eos_facts:
    gather_network_resources: l3_interfaces
  become: yes

- name: Merge provided configuration with device configuration.
  eos_l3_interfaces:
    config: "{{ config }}"
    state: merged
  register: result
  become: yes

- assert:
    that:
      - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.before) == []"

- eos_facts:
    gather_network_resources: l3_interfaces
  become: yes

- assert:
    that:
      - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(result.after) == []"
  become: yes

- set_fact:
    expected_config:
      - name: Ethernet1
        ipv4:
          - address: 198.51.100.14/24
          - address: 203.0.113.27/31
            secondary: true
      - name: Ethernet2
        ipv4:
          - address: 203.0.113.227/31
        ipv6:
          - address: 2001:db8::1/64
      - name: Management1
        ipv4:
          - address: dhcp

- assert:
    that:
      - "ansible_facts.network_resources.l3_interfaces|symmetric_difference(expected_config) == []"
