refactor ♻️: Refactor task to dynamically detect physical NIC backing a bridge, excluding tap and fw interfaces.

This refactoring updates the task logic to dynamically identify the physical network interface card (NIC) backing a bridge, while excluding interfaces of types tap and fw. This change enhances the flexibility and accuracy of network configuration detection.
This commit is contained in:
2025-12-23 20:52:54 +01:00
parent 963b0dff6a
commit 908571b92d

View File

@@ -14,15 +14,16 @@
changed_when: false
failed_when: false
- name: Detect physical NIC backing vmbr0
- name: "Detect physical NIC backing {{ wol_bridge }}"
ansible.builtin.set_fact:
wol_detected_phy: >-
{{
bridge_links.stdout_lines
| select('search', wol_bridge)
| select('search', 'master ' ~ wol_bridge)
| map('regex_search', '^\\d+: ([^:@]+)', '\\1')
| select('string')
| map('regex_replace', '^\\d+: ([^:@]+).*', '\\1')
| reject('search', '^tap')
| reject('search', '^fw')
| reject('equalto', '')
| first
}}