refactor ♻️: Refactored WOL packet capture and validation logic
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s

Improved the efficiency and readability of the WOL packet handling by refactoring the existing code. This includes restructuring the validation logic and optimizing the capture process.
This commit is contained in:
2026-01-25 08:30:39 +01:00
parent 21ec247569
commit d0774ff2b3

View File

@@ -115,11 +115,11 @@
WOL Mode: {{ wol_mode }}
MAC Addresses: {{ wol_mac_addresses | join(', ') }}
- name: Start tcpdump to capture WOL packet
become: true
ansible.builtin.shell: |
tcpdump -i {{ en_interfaces[0] }} -nn -c 1 udp port {{ wol_port }}
timeout 10 tcpdump -i {{ en_interfaces[0] }} -nn -c 1 \
'udp and port {{ wol_port }} and (udp[8:4] = 0xffffffff)'
register: tcpdump_result
async: 12
poll: 0
@@ -142,6 +142,6 @@
- name: Check if WOL packet was received
ansible.builtin.assert:
that:
- "'UDP' in tcpdump_status.stdout"
success_msg: "✅ Wake-on-LAN packet received by host"
fail_msg: "❌ No Wake-on-LAN packet detected"
- tcpdump_status.rc == 0
success_msg: "✅ Wake-on-LAN magic packet received by host"
fail_msg: "❌ Wake-on-LAN magic packet NOT detected"