refactor ♻️: Refactor WOL status extraction to handle multiple matches safely.
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
+7 -2
View File
@@ -44,14 +44,19 @@
msg: > msg: >
{{ wol_check.results | map(attribute='stdout_lines') | list }} {{ 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: ansible.builtin.set_fact:
wol_status: >- wol_status: >-
{{ {{
wol_status | default({}) | wol_status | default({}) |
combine({ combine({
item.item: 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 }}" loop: "{{ wol_check.results }}"