From e9befb965dc84db80e2f890611ef77c5faf94898 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 23 Dec 2025 22:19:24 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20tas?= =?UTF-8?q?k=20logic=20for=20detecting=20and=20reporting=20Wake-on-LAN=20i?= =?UTF-8?q?nterfaces,=20remove=20redundant=20debug=20tasks.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the task logic to improve the detection and reporting of Wake-on-LAN interfaces. It also removes redundant debug tasks to clean up the codebase. --- tasks/main.yml | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index e940b91..8ee6692 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -47,12 +47,12 @@ {{ wol_detected_interfaces | combine({ item: ( - [ - line | regex_search('^\\d+: ([a-z0-9@.]+):', '\\1') | first - for line in bridge_links.stdout_lines - if ('master ' ~ item) in line - and not line is search('^\\d+: (veth|tap|fw)') - ] + bridge_links.stdout_lines + | select('search', 'master ' ~ item) + | map('regex_search', '^\\d+: ([a-z0-9@.]+):', '\\1') + | map('first') + | select('defined') + | reject('search', '^(veth|tap|fw)') | first | default('') ) }) @@ -234,25 +234,3 @@ - {{ iface }}: {{ mac | default('Unable to detect') }} {% endfor %} {% endif %} - when: - - wol_report_mac - - wol_mac_address | length == 0 - -- name: Show WOL status - ansible.builtin.debug: - msg: "{{ wol_status.stdout_lines }}" - when: wol_verify - -- name: Report Wake-on-LAN sender details - ansible.builtin.debug: - msg: - - "Wake-on-LAN enabled successfully" - - "Bridge: {{ wol_bridge }}" - - "Physical NIC: {{ wol_detected_phy }}" - - "MAC address: {{ wol_mac_address }}" - - "Example commands:" - - " wakeonlan {{ wol_mac_address }}" - - " etherwake {{ wol_mac_address }}" - - "Home Assistant:" - - " mac: {{ wol_mac_address }}" - when: wol_report_mac