From a9fdcd6f564a4acf153225a103c84865f976a5bf Mon Sep 17 00:00:00 2001 From: Jose Date: Wed, 24 Dec 2025 10:10:02 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20WOL?= =?UTF-8?q?=20validation=20with=20ethtool=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removed old WOL validation logic and implemented new functionality using ethtool to detect interfaces and display capabilities. --- tasks/main.yml | 67 +++++++------------------------------------------- 1 file changed, 9 insertions(+), 58 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 13bd15f..f5750ec 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -31,66 +31,17 @@ msg: > {{ en_interfaces }} -# # ============================================================ -# # Normalize and validate configuration -# # ============================================================ -# - name: Set WOL bridges list (handle string or list) -# ansible.builtin.set_fact: -# wol_bridges_list: "{{ wol_bridges if wol_bridges is iterable and wol_bridges is not string else [wol_bridges] }}" +- name: Validate WOL capability using ethtool for detected interfaces + ansible.builtin.command: "ethtool {{ en_interfaces }}" + register: wol_capabilities_check + changed_when: false + failed_when: false -# - name: Validate WOL bridges list is not empty -# ansible.builtin.assert: -# that: -# - wol_bridges_list | length > 0 -# fail_msg: "wol_bridges must contain at least one bridge interface" +- name: Display ethtool output for detected interfaces + ansible.builtin.debug: + msg: > + {{ wol_capabilities_check.stdout_lines }}" -# # ============================================================ -# # Detect physical NICs with WOL support using Ansible facts -# # ============================================================ -# - name: Gather network interface facts -# ansible.builtin.setup: -# gather_subset: -# - network -# when: ansible_facts.interfaces is not defined - -# - name: Get all physical network interfaces with WOL support -# ansible.builtin.set_fact: -# wol_capable_interfaces: >- -# {{ -# ansible_facts.interfaces -# | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({})) -# | selectattr('type', 'defined') -# | selectattr('type', 'equalto', 'ether') -# | selectattr('device', 'defined') -# | rejectattr('device', 'search', '^(veth|tap|fw|lo|docker|br)') -# | map(attribute='device') -# | list -# }} - -# - name: Validate WOL capability using ethtool for detected interfaces -# ansible.builtin.command: "ethtool {{ item }}" -# register: wol_capabilities_check -# changed_when: false -# failed_when: false -# loop: "{{ wol_capable_interfaces }}" -# loop_control: -# label: "{{ item }}" - -# - name: Filter interfaces that actually support WOL -# ansible.builtin.set_fact: -# wol_supported_interfaces: >- -# {{ -# wol_capabilities_check.results -# | selectattr('stdout', 'search', 'Supports Wake-on:.*[gGdDpPuU]') -# | map(attribute='item') -# | list -# }} - -# - name: Fail if no interfaces support WOL -# ansible.builtin.assert: -# that: -# - wol_supported_interfaces | length > 0 -# fail_msg: "No network interfaces found that support Wake-on-LAN. Check BIOS settings and NIC capabilities." # # ============================================================ # # Map bridges to physical NICs using Ansible facts