# SPDX-License-Identifier: BSD-3-Clause
- name: Set version specific variables
  include_vars: "{{ item }}"
  with_first_found:
      - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
      - "{{ ansible_distribution }}.yml"
      - "{{ ansible_os_family }}.yml"
      - "default.yml"

- name: Install packages
  package:
      name: "{{ network_packages }}"
      state: present

- name: Enable network service
  service:
      name: "{{ network_service_name }}"
      state: started
      enabled: yes

- name: Configure networking connection profiles
  network_connections:
      provider:            "{{ network_provider           | mandatory }}"
      ignore_errors:       "{{ network_ignore_errors      | default(omit) }}"
      force_state_change:  "{{ network_force_state_change | default(omit) }}"
      connections:         "{{ network_connections        | default([]) }}"

- name: Re-test connectivity
  ping:

# SPDX-License-Identifier: BSD-3-Clause
- name: Set version specific variables
  include_vars: "{{ item }}"
  with_first_found:
      - "{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml"
      - "{{ ansible_distribution }}.yml"
      - "{{ ansible_os_family }}.yml"
      - "default.yml"

# needed for ansible_facst.packages
- name: Check which packages are installed
  package_facts:

# Depending on the plugins, checking installed packages might be slow
# for example subscription manager might slow this down
# Therefore install packages only when rpm does not find them
- name: Install packages
  package:
      name: "{{ network_packages }}"
      state: present
  when:
    - not network_packages is subset(ansible_facts.packages.keys())

- name: Enable network service
  service:
      name: "{{ network_service_name }}"
      state: started
      enabled: yes

- name: Configure networking connection profiles
  network_connections:
      provider:            "{{ network_provider           | mandatory }}"
      ignore_errors:       "{{ network_ignore_errors      | default(omit) }}"
      force_state_change:  "{{ network_force_state_change | default(omit) }}"
      connections:         "{{ network_connections        | default([]) }}"

- name: Re-test connectivity
  ping:

Work around slow package manager
Work around slow package manager
