# SPDX-License-Identifier: BSD-3-Clause
---
- name: Test configuring bridges
  hosts: all
  vars:
    interface: LSR-TST-br31
  tasks:
    - name: Include the task 'show_interfaces.yml'
      include_tasks: tasks/show_interfaces.yml

    - name: Include the task 'assert_device_absent.yml'
      include_tasks: tasks/assert_device_absent.yml

    - name: Add test bridge
      include_role:
        name: linux-system-roles.network
      vars:
        network_connections:
          - name: "{{ interface }}"
            interface_name: "{{ interface }}"
            state: up
            type: bridge
            ip:
              dhcp4: false
              auto6: true

    - name: Assert device present
      include_tasks: tasks/assert_device_present.yml

    - name: Assert profile present
      include_tasks: tasks/assert_profile_present.yml
      vars:
        profile: "{{ interface }}"

    - name: Include the task 'down_profile+delete_interface.yml'
      include_tasks: tasks/down_profile+delete_interface.yml
      vars:
        profile: "{{ interface }}"
    # FIXME: assert profile/device down

    - name: Include the task 'remove_profile.yml'
      include_tasks: tasks/remove_profile.yml
      vars:
        profile: "{{ interface }}"

    - name: Assert profile absent
      include_tasks: tasks/assert_profile_absent.yml
      vars:
        profile: "{{ interface }}"

    - name: Assert device absent
      include_tasks: tasks/assert_device_absent.yml

    - name: Verify network state restored to default
      include_tasks: tasks/check_network_dns.yml
