refactor ♻️: Refactor Wake-on-LAN support logic and comment out the enable command
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 15s

This commit refactors the Wake-on-LAN (WOL) support logic to improve readability and maintainability. Additionally, it comments out the enable command as part of a larger refactoring effort.
This commit is contained in:
2025-12-25 21:30:57 +01:00
parent c52fb6c563
commit f6d35d0abb

View File

@@ -53,18 +53,14 @@
item.item: {
'supports_magic':
(
item.stdout_lines
| select('search', '^\\s*Supports Wake-on:')
| map('regex_replace', '^\\s*Supports Wake-on:\\s*', '')
| first
item.stdout
| regex_search('Supports Wake-on:\\s*([a-z]+)', '\\1')
| default('')
).find('g') != -1,
'current_state':
(
item.stdout_lines
| select('search', '^\\s*Wake-on:')
| map('regex_replace', '^\\s*Wake-on:\\s*', '')
| first
item.stdout
| regex_search('Wake-on:\\s*([a-z]+)', '\\1')
| default('unknown')
)
}
@@ -72,13 +68,6 @@
}}
loop: "{{ wol_check.results }}"
- name: Enable Wake-on-LAN (magic packet) when supported
ansible.builtin.command: "ethtool -s {{ item.key }} wol g"
when:
- item.value.supports_magic
- item.value.current_state != 'g'
loop: "{{ wol_info | dict2items }}"
- name: Display WOL status summary
ansible.builtin.debug:
msg: >
@@ -88,6 +77,14 @@
loop: "{{ wol_info | dict2items }}"
# - name: Enable Wake-on-LAN (magic packet) when supported
# ansible.builtin.command: "ethtool -s {{ item.key }} wol g"
# when:
# - item.value.supports_magic
# - item.value.current_state != 'g'
# loop: "{{ wol_info | dict2items }}"
# # ============================================================
# # Map bridges to physical NICs using Ansible facts
# # ============================================================