# SPDX-License-Identifier: BSD-3-Clause
---
- name: Play for testing team plugin installation
  hosts: all
  tasks:
    - name: Check if test can run on ostree systems
      include_tasks: tasks/ostree_systems_check.yml
      vars:
        package: NetworkManager-team

    - name: Remove the NetworkManager-team package
      package:
        name: "NetworkManager-team"
        state: absent

    - name: "Get the rpm package facts"
      package_facts:
        manager: "auto"

    - name: "Assert NetworkManager-team removed before team configuration"
      assert:
        that:
          - "'NetworkManager-team' not in ansible_facts.packages"
        msg: "NetworkManager-team is not removed before team configuration"

    - name: Test the team connection
      tags:
        - tests::team:create
      vars:
        interface: team0
        profile: "{{ interface }}"
        network_allow_restart: true
        network_connections:
          # Specify the team profile
          - name: "{{ interface }}"
            persistent_state: present
            type: team
            interface_name: "{{ interface }}"
        lsr_fail_debug:
          - __network_connections_result
      block:
        - name: Include the task 'run_test.yml'
          include_tasks: tasks/run_test.yml
          vars:
            lsr_description: Create a team interface without any port attached
            lsr_setup:
              - tasks/delete_interface.yml
              - tasks/assert_device_absent.yml
            lsr_test:
              - tasks/create_team_profile.yml
            lsr_assert:
              - tasks/assert_profile_present.yml
              - tasks/assert_device_present.yml
            lsr_cleanup:
              - tasks/cleanup_profile+device.yml
              - tasks/check_network_dns.yml

    - name: "Get the rpm package facts again"
      package_facts:
        manager: "auto"

    - name: "Assert NetworkManager-team is installed after team configuration"
      assert:
        that:
          - "'NetworkManager-team' in ansible_facts.packages"
        msg: "NetworkManager-team is not installed after team configuration"
...
