refactor ♻️: Refactor WOL parsing logic
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 9s
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 9s
Updated WOL parsing to use `select` and `join` for guaranteed matches, improving reliability.
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
msg: >
|
msg: >
|
||||||
{{ wol_check.results | map(attribute='stdout_lines') | list }}
|
{{ wol_check.results | map(attribute='stdout_lines') | list }}
|
||||||
|
|
||||||
- name: Parse WOL support and state (exception-safe)
|
- name: Parse WOL support and state (guaranteed match)
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
wol_info: >-
|
wol_info: >-
|
||||||
{{
|
{{
|
||||||
@@ -53,15 +53,15 @@
|
|||||||
item.item: {
|
item.item: {
|
||||||
'supports_magic':
|
'supports_magic':
|
||||||
(
|
(
|
||||||
item.stdout
|
item.stdout_lines
|
||||||
| regex_findall('Supports Wake-on:\\s*([a-z]+)')
|
| select('search', 'Supports Wake-on:')
|
||||||
| first
|
| join('')
|
||||||
| default('')
|
|
||||||
).find('g') != -1,
|
).find('g') != -1,
|
||||||
'current_state':
|
'current_state':
|
||||||
(
|
(
|
||||||
item.stdout
|
item.stdout_lines
|
||||||
| regex_findall('Wake-on:\\s*([a-z]+)')
|
| select('search', '^\\s*Wake-on:')
|
||||||
|
| map('regex_replace', '.*Wake-on:\\s*', '')
|
||||||
| first
|
| first
|
||||||
| default('unknown')
|
| default('unknown')
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user