From f6d35d0abb3ea8ddc2c183d7604e8f1cef57d9eb Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 25 Dec 2025 21:30:57 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20Wak?= =?UTF-8?q?e-on-LAN=20support=20logic=20and=20comment=20out=20the=20enable?= =?UTF-8?q?=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the Wake-on-LAN (WOL) support logic to improve readability and maintainability. Additionally, it comments out the enable command as part of a larger refactoring effort. --- tasks/main.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index cce793d..da60dbd 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -53,18 +53,14 @@ item.item: { 'supports_magic': ( - item.stdout_lines - | select('search', '^\\s*Supports Wake-on:') - | map('regex_replace', '^\\s*Supports Wake-on:\\s*', '') - | first + item.stdout + | regex_search('Supports Wake-on:\\s*([a-z]+)', '\\1') | default('') ).find('g') != -1, 'current_state': ( - item.stdout_lines - | select('search', '^\\s*Wake-on:') - | map('regex_replace', '^\\s*Wake-on:\\s*', '') - | first + item.stdout + | regex_search('Wake-on:\\s*([a-z]+)', '\\1') | default('unknown') ) } @@ -72,13 +68,6 @@ }} loop: "{{ wol_check.results }}" -- name: Enable Wake-on-LAN (magic packet) when supported - ansible.builtin.command: "ethtool -s {{ item.key }} wol g" - when: - - item.value.supports_magic - - item.value.current_state != 'g' - loop: "{{ wol_info | dict2items }}" - - name: Display WOL status summary ansible.builtin.debug: msg: > @@ -88,6 +77,14 @@ loop: "{{ wol_info | dict2items }}" +# - name: Enable Wake-on-LAN (magic packet) when supported +# ansible.builtin.command: "ethtool -s {{ item.key }} wol g" +# when: +# - item.value.supports_magic +# - item.value.current_state != 'g' +# loop: "{{ wol_info | dict2items }}" + + # # ============================================================ # # Map bridges to physical NICs using Ansible facts # # ============================================================