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>
176 lines
6 KiB
YAML
176 lines
6 KiB
YAML
# SPDX-License-Identifier: BSD-3-Clause
|
|
---
|
|
- name: Play for testing ethtool coalesce settings
|
|
hosts: all
|
|
vars:
|
|
interface: testnic1
|
|
type: veth
|
|
tasks:
|
|
- name: Show playbook name
|
|
debug:
|
|
msg: "this is: playbooks/tests_ethtool_coalesce.yml"
|
|
tags:
|
|
- always
|
|
|
|
- name: "INIT: Ethtool coalesce tests"
|
|
debug:
|
|
msg: "##################################################"
|
|
- name: Include the task 'show_interfaces.yml'
|
|
include_tasks: tasks/show_interfaces.yml
|
|
- name: Include the task 'manage_test_interface.yml'
|
|
include_tasks: tasks/manage_test_interface.yml
|
|
vars:
|
|
state: present
|
|
- name: Include the task 'assert_device_present.yml'
|
|
include_tasks: tasks/assert_device_present.yml
|
|
- name: Install ethtool (test dependency)
|
|
package:
|
|
name: ethtool
|
|
state: present
|
|
use: "{{ (__network_is_ostree | d(false)) |
|
|
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
|
|
|
|
- name: Test ethtool coalesce settings
|
|
block:
|
|
- name: >-
|
|
TEST: I can create a profile without any coalescing option.
|
|
debug:
|
|
msg: "##################################################"
|
|
- name: Import network role
|
|
import_role:
|
|
name: linux-system-roles.network
|
|
vars:
|
|
network_connections:
|
|
- name: "{{ interface }}"
|
|
type: ethernet
|
|
state: up
|
|
ip:
|
|
dhcp4: false
|
|
auto6: false
|
|
|
|
- name: Get profile's coalescing options
|
|
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
|
|
register: no_coalesce_nm
|
|
when:
|
|
- network_provider == "nm"
|
|
changed_when: false
|
|
- name: "ASSERT: The profile does not contain coalescing options"
|
|
assert:
|
|
that: no_coalesce_nm.stdout | length == 0
|
|
when:
|
|
- network_provider == "nm"
|
|
- name: Get profile's coalescing options
|
|
command:
|
|
grep ETHTOOL /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
|
|
register: no_coalesce_initscripts
|
|
ignore_errors: true
|
|
when:
|
|
- network_provider == "initscripts"
|
|
changed_when: false
|
|
- name: "ASSERT: The profile does not contain coalescing options"
|
|
assert:
|
|
that: no_coalesce_initscripts.stdout | length == 0
|
|
when:
|
|
- network_provider == "initscripts"
|
|
|
|
- name: >-
|
|
TEST: I can set rx-frames.
|
|
debug:
|
|
msg: "##################################################"
|
|
- name: Import network role
|
|
import_role:
|
|
name: linux-system-roles.network
|
|
vars:
|
|
network_connections:
|
|
- name: "{{ interface }}"
|
|
type: ethernet
|
|
state: up
|
|
ip:
|
|
dhcp4: false
|
|
auto6: false
|
|
ethtool:
|
|
coalesce:
|
|
rx_frames: 128
|
|
- name: Get profile's coalescing options
|
|
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
|
|
register: with_coalesce_nm
|
|
when:
|
|
- network_provider == "nm"
|
|
changed_when: false
|
|
- name: Assert coalesce options set in profile
|
|
assert:
|
|
that: with_coalesce_nm.stdout == '128'
|
|
when:
|
|
- network_provider == "nm"
|
|
|
|
- name: Get profile's coalescing options
|
|
command:
|
|
grep ETHTOOL /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
|
|
register: with_coalesce_initscripts
|
|
ignore_errors: true
|
|
when:
|
|
- network_provider == "initscripts"
|
|
changed_when: false
|
|
- name: Assert coalesce options set in profile
|
|
assert:
|
|
that: '"rx-frames 128" in with_coalesce_initscripts.stdout'
|
|
when:
|
|
- network_provider == "initscripts"
|
|
|
|
- name: "TEST: I can clear coalescing options"
|
|
debug:
|
|
msg: "##################################################"
|
|
- name: Import network role
|
|
import_role:
|
|
name: linux-system-roles.network
|
|
vars:
|
|
network_connections:
|
|
- name: "{{ interface }}"
|
|
type: ethernet
|
|
state: up
|
|
ip:
|
|
dhcp4: false
|
|
auto6: false
|
|
|
|
- name: Get profile's coalescing options
|
|
command: nmcli -g ethtool.coalesce-rx-frames c show {{ interface }}
|
|
when:
|
|
- network_provider == "nm"
|
|
register: clear_coalesce_nm
|
|
changed_when: false
|
|
- name: "ASSERT: The profile does reset coalescing options"
|
|
assert:
|
|
that: clear_coalesce_nm.stdout | length == 0
|
|
when:
|
|
- network_provider == "nm"
|
|
- name: Get profile's coalescing options
|
|
command:
|
|
grep ETHTOOL /etc/sysconfig/network-scripts/ifcfg-{{ interface }}
|
|
register: clear_coalesce_initscripts
|
|
ignore_errors: true
|
|
when:
|
|
- network_provider == "initscripts"
|
|
changed_when: false
|
|
- name: "ASSERT: The profile does reset coalescing options"
|
|
assert:
|
|
that: clear_coalesce_initscripts.stdout | length == 0
|
|
when:
|
|
- network_provider == "initscripts"
|
|
|
|
always:
|
|
- name: Clean up the test device and the connection profile
|
|
tags:
|
|
- "tests::cleanup"
|
|
block:
|
|
- name: Import network role
|
|
import_role:
|
|
name: linux-system-roles.network
|
|
vars:
|
|
network_connections:
|
|
- name: "{{ interface }}"
|
|
persistent_state: absent
|
|
failed_when: false
|
|
- name: Include the task 'manage_test_interface.yml'
|
|
include_tasks: tasks/manage_test_interface.yml
|
|
vars:
|
|
state: absent
|