From 6a5c9f59676b3ba824242f71cf11a11fa713f6e2 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 09:19:47 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Simplify=20Wak?= =?UTF-8?q?e-on-LAN=20task=20loop=20variables=20and=20conditions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored the Wake-on-LAN task to use more concise and readable loop variables and conditions, improving code clarity without altering its functionality. --- tasks/main.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5a16026..d19c18b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,20 +57,13 @@ when: en_interfaces | length > 0 - name: Enable Wake-on-LAN (magic packet) when supported - ansible.builtin.command: "ethtool -s {{ item.interface }} wol g" + ansible.builtin.command: "ethtool -s {{ item.0 }} wol g" loop: "{{ en_interfaces | zip(wol_enabled.results, wol_supported.results) | list }}" loop_control: label: "{{ item.0 }}" - vars: - # item.0 = interface - # item.1 = wol_enabled result - # item.2 = wol_supported result - interface: "{{ item.0 }}" - wol_enabled_result: "{{ item.1 }}" - wol_supported_result: "{{ item.2 }}" when: - - "'g' not in wol_enabled_result.stdout" - - "'g' in wol_supported_result.stdout" + - "'g' not in item.1.stdout" + - "'g' in item.2.stdout" # # ============================================================