mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
test: find second interface to use for mac address match
Some systems do not use the `ethN` interface naming scheme, and use `ensN` instead. The test wants to use `eth1` as the second interface. If this does not exist, try `ens4` instead.
This commit is contained in:
parent
89297aa207
commit
7c73334ca5
1 changed files with 19 additions and 1 deletions
|
|
@ -17,7 +17,7 @@
|
|||
# after the parent interface, following the standard `<parent>.<vlan_id>` format.
|
||||
# - `vlan_profile2` (e.g., `120-vlan`) has a fixed name, designed to test a scenario
|
||||
# where lexicographic sorting causes the VLAN to appear before its parent interface.
|
||||
interface: "{{ lookup('env', 'MAC_ADDR_MATCH_INTERFACE') | default('eth1', true) }}"
|
||||
default_interface: "{{ lookup('env', 'MAC_ADDR_MATCH_INTERFACE') | default('eth1', true) }}"
|
||||
profile: "{{ interface }}"
|
||||
vlan_profile1: "{{ interface }}.3732"
|
||||
vlan_profile2: "120-vlan"
|
||||
|
|
@ -39,6 +39,24 @@
|
|||
use: "{{ (__network_is_ostree | d(false)) |
|
||||
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"
|
||||
|
||||
- name: Find interface to use
|
||||
shell:
|
||||
executable: /bin/bash
|
||||
cmd: |
|
||||
set -euxo pipefail
|
||||
for iface in '{{ default_interface }}' ens4; do
|
||||
if ip addr show "$iface" 1>&2; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
echo "$iface"
|
||||
changed_when: false
|
||||
register: __network_interface_cmd
|
||||
|
||||
- name: Set interface to use
|
||||
set_fact:
|
||||
interface: "{{ __network_interface_cmd.stdout | trim }}"
|
||||
|
||||
- name: Retrieve MAC address using ethtool
|
||||
command: ethtool -P {{ interface }}
|
||||
register: mac_address_result
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue