mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
The dependency on `ansible.utils.update_fact` is causing issue with
some users who now must install that collection in order to run
the role, even if they do not care about ostree.
The fix is to stop trying to set `ansible_facts.pkg_mgr`, and instead
force the use of the ostree package manager with the `package:` module
`use:` option. The strategy is - on ostree systems, set the flag
`__$ROLENAME_is_ostree` if the system is an ostree system. The flag
will either be undefined or `false` on non-ostree systems.
Then, change every invocation of the `package:` module like this:
```yaml
- name: Ensure required packages are present
package:
name: "{{ __$ROLENAME_packages }}"
state: present
use: "{{ (__$ROLENAME_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
```
This should ensure that the `use:` parameter is not used if the system
is non-ostree. The goal is to make the ostree support as unobtrusive
as possible for non-ostree systems.
The user can also set `__$ROLENAME_is_ostree: true` in the inventory or play
if the user knows that ostree is being used and wants to skip the check.
Or, the user is concerned about the performance hit for ostree detection
on non-ostree systems, and sets `__$ROLENAME_is_ostree: false` to skip
the check.
The flag `__$ROLENAME_is_ostree` can also be used in the role or tests to
include or exclude tasks from being run on ostree systems.
This fix also improves error reporting in the `get_ostree_data.sh` script
when included roles cannot be found.
Signed-off-by: Rich Megginson <rmeggins@redhat.com>
45 lines
1.5 KiB
YAML
45 lines
1.5 KiB
YAML
# SPDX-License-Identifier: BSD-3-Clause
|
|
# This file was generated by ensure_provider_tests.py
|
|
---
|
|
# set network provider and gather facts
|
|
- hosts: all
|
|
# yamllint disable rule:line-length
|
|
name: Run playbook 'playbooks/tests_ethtool_ring.yml' with nm as provider
|
|
tasks:
|
|
- name: Include the task 'el_repo_setup.yml'
|
|
include_tasks: tasks/el_repo_setup.yml
|
|
- name: Set network provider to 'nm'
|
|
set_fact:
|
|
network_provider: nm
|
|
tags:
|
|
- always
|
|
|
|
- name: Install NetworkManager and get NetworkManager version
|
|
when:
|
|
- ansible_distribution_major_version != '6'
|
|
tags:
|
|
- always
|
|
block:
|
|
- name: Install NetworkManager
|
|
package:
|
|
name: NetworkManager
|
|
state: present
|
|
use: "{{ (__network_is_ostree | d(false)) |
|
|
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
|
|
- name: Get package info
|
|
package_facts:
|
|
- name: Get NetworkManager version
|
|
set_fact:
|
|
networkmanager_version: "{{
|
|
ansible_facts.packages['NetworkManager'][0]['version'] }}"
|
|
|
|
|
|
# The test requires or should run with NetworkManager, therefore it cannot run
|
|
# on RHEL/CentOS 6
|
|
# NetworkManager 1.25.2 introduced ethtool ring support
|
|
- name: Import the playbook 'playbooks/tests_ethtool_ring.yml'
|
|
import_playbook: playbooks/tests_ethtool_ring.yml
|
|
when:
|
|
- ansible_distribution_major_version != '6'
|
|
|
|
- networkmanager_version is version('1.25.2', '>=')
|