refactor ♻️: Refactor WOL status extraction to handle multiple matches safely.
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s
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:
@@ -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 }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user