|
| 1 | +# SPDX-License-Identifier: BSD-3-Clause |
| 2 | +--- |
| 3 | +- name: Play for testing MAC address match on device |
| 4 | + hosts: all |
| 5 | + vars: |
| 6 | + # This test requires an Ethernet interface whose permanent |
| 7 | + # MAC address matches its current MAC address. Ensure that the |
| 8 | + # specified interface meets this condition. |
| 9 | + # |
| 10 | + # Two VLAN profiles are defined to test deterministic behavior when fetching |
| 11 | + # link information from sysfs. The issue being tested arises when `os.listdir(path)` |
| 12 | + # returns interfaces in an arbitrary order, potentially listing a VLAN device |
| 13 | + # before its parent interface. This can cause intermittent "no such interface |
| 14 | + # exists" errors when applying configurations repeatedly. |
| 15 | + # |
| 16 | + # - `vlan_profile1` (e.g., `eth1.3732`) is named with the VLAN ID appended |
| 17 | + # after the parent interface, following the standard `<parent>.<vlan_id>` format. |
| 18 | + # - `vlan_profile2` (e.g., `120-vlan`) has a fixed name, designed to test a scenario |
| 19 | + # where lexicographic sorting causes the VLAN to appear before its parent interface. |
| 20 | + interface: "{{ lookup('env', 'MAC_ADDR_MATCH_INTERFACE') | default('eth1', true) }}" |
| 21 | + profile: "{{ interface }}" |
| 22 | + vlan_profile1: "{{ interface }}.3732" |
| 23 | + vlan_profile2: "120-vlan" |
| 24 | + lsr_fail_debug: |
| 25 | + - __network_connections_result |
| 26 | + tags: |
| 27 | + - "tests::match" |
| 28 | + tasks: |
| 29 | + - name: Show playbook name |
| 30 | + debug: |
| 31 | + msg: "this is: playbooks/tests_mac_address_match.yml" |
| 32 | + tags: |
| 33 | + - always |
| 34 | + |
| 35 | + - name: Install ethtool (test dependency) |
| 36 | + package: |
| 37 | + name: ethtool |
| 38 | + state: present |
| 39 | + use: "{{ (__network_is_ostree | d(false)) | |
| 40 | + ternary('ansible.posix.rhel_rpm_ostree', omit) }}" |
| 41 | + |
| 42 | + - name: Retrieve MAC address using ethtool |
| 43 | + command: ethtool -P {{ interface }} |
| 44 | + register: mac_address_result |
| 45 | + changed_when: false |
| 46 | + failed_when: mac_address_result.rc != 0 |
| 47 | + |
| 48 | + - name: Set the MAC address variable |
| 49 | + set_fact: |
| 50 | + mac: "{{ mac_address_result.stdout_lines[-1].split(' ')[-1] }}" |
| 51 | + |
| 52 | + - name: Display the retrieved MAC address |
| 53 | + debug: |
| 54 | + msg: "Retrieved MAC address for {{ interface }}: {{ mac }}" |
| 55 | + |
| 56 | + - name: Test the MAC address match |
| 57 | + tags: |
| 58 | + - tests::match:match |
| 59 | + block: |
| 60 | + - name: Include the task 'run_test.yml' |
| 61 | + include_tasks: tasks/run_test.yml |
| 62 | + vars: |
| 63 | + lsr_description: Test MAC address match on device |
| 64 | + lsr_setup: |
| 65 | + - tasks/find+remove_profile.yml |
| 66 | + - tasks/assert_profile_absent.yml |
| 67 | + lsr_test: |
| 68 | + - tasks/create_mac_address_match.yml |
| 69 | + - tasks/create_mac_address_match.yml |
| 70 | + lsr_assert: |
| 71 | + - tasks/assert_profile_present.yml |
| 72 | + - tasks/assert_network_connections_succeeded.yml |
| 73 | + lsr_cleanup: |
| 74 | + - tasks/cleanup_vlan_and_parent_profile+device.yml |
| 75 | + - tasks/check_network_dns.yml |
0 commit comments