refactor ♻️: Refactored WOL packet capture and validation logic
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
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:
@@ -115,11 +115,11 @@
|
|||||||
WOL Mode: {{ wol_mode }}
|
WOL Mode: {{ wol_mode }}
|
||||||
MAC Addresses: {{ wol_mac_addresses | join(', ') }}
|
MAC Addresses: {{ wol_mac_addresses | join(', ') }}
|
||||||
|
|
||||||
|
|
||||||
- name: Start tcpdump to capture WOL packet
|
- name: Start tcpdump to capture WOL packet
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.shell: |
|
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
|
register: tcpdump_result
|
||||||
async: 12
|
async: 12
|
||||||
poll: 0
|
poll: 0
|
||||||
@@ -142,6 +142,6 @@
|
|||||||
- name: Check if WOL packet was received
|
- name: Check if WOL packet was received
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- "'UDP' in tcpdump_status.stdout"
|
- tcpdump_status.rc == 0
|
||||||
success_msg: "✅ Wake-on-LAN packet received by host"
|
success_msg: "✅ Wake-on-LAN magic packet received by host"
|
||||||
fail_msg: "❌ No Wake-on-LAN packet detected"
|
fail_msg: "❌ Wake-on-LAN magic packet NOT detected"
|
||||||
Reference in New Issue
Block a user