From 6e8a9d76314c6a5483850ec601590dd7f039cb85 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 07:10:05 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20reg?= =?UTF-8?q?ex=20search=20to=20use=20`regex=5Ffindall`=20and=20add=20condit?= =?UTF-8?q?ion=20to=20check=20if=20stdout=20is=20defined?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the regex search functionality by replacing the existing method with `regex_findall`. Additionally, it adds a conditional check to ensure that `stdout` is defined before proceeding with the search operation. --- tasks/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 3056f6b..39e7b10 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -57,9 +57,11 @@ ansible.builtin.debug: msg: > Interface {{ item.item }}: - Supported={{ item.stdout | regex_search('Supports Wake-on: (.+)', '\\1') | default('unknown') }}, - Current={{ item.stdout | regex_search('Wake-on: (.+)', '\\1') | default('unknown') }} + Supported={{ (item.stdout | regex_findall('Supports Wake-on: (.+)') | first) | default('unknown') }}, + Current={{ (item.stdout | regex_findall('Wake-on: (.+)') | first) | default('unknown') }} loop: "{{ wol_status.results }}" + when: item.stdout is defined + # - name: Enable Wake-on-LAN (magic packet) when supported