refactor ♻️: Refactor regex search to use regex_findall and add condition to check if stdout is defined
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s

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.
This commit is contained in:
2025-12-26 07:10:05 +01:00
parent 5f34c4e959
commit 6e8a9d7631

View File

@@ -57,9 +57,11 @@
ansible.builtin.debug: ansible.builtin.debug:
msg: > msg: >
Interface {{ item.item }}: Interface {{ item.item }}:
Supported={{ item.stdout | regex_search('Supports Wake-on: (.+)', '\\1') | default('unknown') }}, Supported={{ (item.stdout | regex_findall('Supports Wake-on: (.+)') | first) | default('unknown') }},
Current={{ item.stdout | regex_search('Wake-on: (.+)', '\\1') | default('unknown') }} Current={{ (item.stdout | regex_findall('Wake-on: (.+)') | first) | default('unknown') }}
loop: "{{ wol_status.results }}" loop: "{{ wol_status.results }}"
when: item.stdout is defined
# - name: Enable Wake-on-LAN (magic packet) when supported # - name: Enable Wake-on-LAN (magic packet) when supported