From 5f34c4e95994ca09ce3cc3e758f8dcf452e0990b Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 07:07:30 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20she?= =?UTF-8?q?ll=20and=20debug=20tasks=20to=20use=20ansible.builtin=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated the shell and debug tasks to utilize `ansible.builtin` modules, enhancing compatibility and improving code clarity. --- tasks/main.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index f703c3f..3056f6b 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -41,7 +41,7 @@ {{ en_interfaces }} - name: Check WoL status with ethtool - shell: "ethtool {{ item }} | grep 'Wake-on'" + ansible.builtin.shell: "ethtool {{ item }} | grep 'Wake-on'" register: wol_status changed_when: false failed_when: false @@ -49,17 +49,17 @@ when: en_interfaces | length > 0 - name: Display WoL status - debug: - msg: "{{ item.item }}: {{ item.stdout | default('No output') }}" + ansible.builtin.debug: + msg: "{{ item.item }}:\n{{ item.stdout | default('No output') }}" loop: "{{ wol_status.results }}" -- name: Display WOL status summary +- name: Display WoL status summary ansible.builtin.debug: msg: > - Interface {{ item.key }}: - Supported={{ item.value.supports_magic }}, - Current={{ item.value.current_state }} - loop: "{{ wol_info | dict2items }}" + Interface {{ item.item }}: + Supported={{ item.stdout | regex_search('Supports Wake-on: (.+)', '\\1') | default('unknown') }}, + Current={{ item.stdout | regex_search('Wake-on: (.+)', '\\1') | default('unknown') }} + loop: "{{ wol_status.results }}" # - name: Enable Wake-on-LAN (magic packet) when supported