refactor ♻️: Refactor WOL status extraction to handle multiple matches safely.
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s

This refactoring improves the handling of multiple matches in the WOL status extraction process, ensuring more robust and reliable results.
This commit is contained in:
2025-12-24 10:48:26 +01:00
parent 3125c4f230
commit 1112e01cbf

View File

@@ -44,14 +44,19 @@
msg: >
{{ wol_check.results | map(attribute='stdout_lines') | list }}
- name: Build WOL status per interface
- name: Build WOL status per interface (safe)
ansible.builtin.set_fact:
wol_status: >-
{{
wol_status | default({}) |
combine({
item.item:
(item.stdout | regex_search('Wake-on:\\s*(\\S+)', '\\1') | default('Not supported'))
(
item.stdout
| regex_findall('Wake-on:\\s*(\\S+)')
| first
| default('Not supported')
)
})
}}
loop: "{{ wol_check.results }}"