refactor ♻️: Refactor WOL validation with ethtool command
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 11s
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 11s
Removed old WOL validation logic and implemented new functionality using ethtool to detect interfaces and display capabilities.
This commit is contained in:
@@ -31,66 +31,17 @@
|
|||||||
msg: >
|
msg: >
|
||||||
{{ en_interfaces }}
|
{{ en_interfaces }}
|
||||||
|
|
||||||
# # ============================================================
|
- name: Validate WOL capability using ethtool for detected interfaces
|
||||||
# # Normalize and validate configuration
|
ansible.builtin.command: "ethtool {{ en_interfaces }}"
|
||||||
# # ============================================================
|
register: wol_capabilities_check
|
||||||
# - name: Set WOL bridges list (handle string or list)
|
changed_when: false
|
||||||
# ansible.builtin.set_fact:
|
failed_when: false
|
||||||
# wol_bridges_list: "{{ wol_bridges if wol_bridges is iterable and wol_bridges is not string else [wol_bridges] }}"
|
|
||||||
|
|
||||||
# - name: Validate WOL bridges list is not empty
|
- name: Display ethtool output for detected interfaces
|
||||||
# ansible.builtin.assert:
|
ansible.builtin.debug:
|
||||||
# that:
|
msg: >
|
||||||
# - wol_bridges_list | length > 0
|
{{ wol_capabilities_check.stdout_lines }}"
|
||||||
# fail_msg: "wol_bridges must contain at least one bridge interface"
|
|
||||||
|
|
||||||
# # ============================================================
|
|
||||||
# # Detect physical NICs with WOL support using Ansible facts
|
|
||||||
# # ============================================================
|
|
||||||
# - name: Gather network interface facts
|
|
||||||
# ansible.builtin.setup:
|
|
||||||
# gather_subset:
|
|
||||||
# - network
|
|
||||||
# when: ansible_facts.interfaces is not defined
|
|
||||||
|
|
||||||
# - name: Get all physical network interfaces with WOL support
|
|
||||||
# ansible.builtin.set_fact:
|
|
||||||
# wol_capable_interfaces: >-
|
|
||||||
# {{
|
|
||||||
# ansible_facts.interfaces
|
|
||||||
# | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}))
|
|
||||||
# | selectattr('type', 'defined')
|
|
||||||
# | selectattr('type', 'equalto', 'ether')
|
|
||||||
# | selectattr('device', 'defined')
|
|
||||||
# | rejectattr('device', 'search', '^(veth|tap|fw|lo|docker|br)')
|
|
||||||
# | map(attribute='device')
|
|
||||||
# | list
|
|
||||||
# }}
|
|
||||||
|
|
||||||
# - name: Validate WOL capability using ethtool for detected interfaces
|
|
||||||
# ansible.builtin.command: "ethtool {{ item }}"
|
|
||||||
# register: wol_capabilities_check
|
|
||||||
# changed_when: false
|
|
||||||
# failed_when: false
|
|
||||||
# loop: "{{ wol_capable_interfaces }}"
|
|
||||||
# loop_control:
|
|
||||||
# label: "{{ item }}"
|
|
||||||
|
|
||||||
# - name: Filter interfaces that actually support WOL
|
|
||||||
# ansible.builtin.set_fact:
|
|
||||||
# wol_supported_interfaces: >-
|
|
||||||
# {{
|
|
||||||
# wol_capabilities_check.results
|
|
||||||
# | selectattr('stdout', 'search', 'Supports Wake-on:.*[gGdDpPuU]')
|
|
||||||
# | map(attribute='item')
|
|
||||||
# | list
|
|
||||||
# }}
|
|
||||||
|
|
||||||
# - name: Fail if no interfaces support WOL
|
|
||||||
# ansible.builtin.assert:
|
|
||||||
# that:
|
|
||||||
# - wol_supported_interfaces | length > 0
|
|
||||||
# fail_msg: "No network interfaces found that support Wake-on-LAN. Check BIOS settings and NIC capabilities."
|
|
||||||
|
|
||||||
# # ============================================================
|
# # ============================================================
|
||||||
# # Map bridges to physical NICs using Ansible facts
|
# # Map bridges to physical NICs using Ansible facts
|
||||||
|
|||||||
Reference in New Issue
Block a user