From 1647839c8cbdc814f82a3c2c1be0a71e9642bb9e Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 12:08:19 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Simplify=20and?= =?UTF-8?q?=20update=20task=20reporting?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored the task reporting process to improve clarity and efficiency, updating the code logic while maintaining external behavior. --- tasks/main.yml | 65 +++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 48 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 11ad2e8..7a828f8 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -74,52 +74,21 @@ - wol_mode == 'd' - wol_mode not in item.1.stdout -# # ============================================================ -# # Verification & Reporting -# # ============================================================ -# - name: Verify Wake-on-LAN status -# ansible.builtin.command: "ethtool {{ item }}" -# register: wol_status -# changed_when: false -# loop: "{{ wol_final_interfaces }}" -# loop_control: -# label: "{{ item }}" -# when: wol_verify +- name: Get MAC addresses + ansible.builtin.set_fact: + wol_mac_addresses: >- + {{ + en_interfaces + | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}), 'macaddress') + | list + }} -# - name: Display WOL status per interface -# ansible.builtin.debug: -# msg: > -# Interface {{ item.item }} WOL Status: -# {{ item.stdout_lines | select('search', 'Wake-on:') | first | default('Status Unknown') }} -# loop: "{{ wol_status.results | default([]) }}" -# loop_control: -# label: "{{ item.item }}" -# when: wol_verify - -# - name: Get MAC addresses for all interfaces -# ansible.builtin.set_fact: -# wol_mac_addresses: >- -# {{ -# wol_final_interfaces -# | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}), 'macaddress') -# | list -# }} - -# - name: Report WOL configuration -# ansible.builtin.debug: -# msg: | -# Wake-on-LAN Configuration Summary: -# =================================== -# Bridges Configured: {{ wol_bridges_list | join(', ') }} -# Physical Interfaces: {{ wol_final_interfaces | join(', ') }} -# WOL Mode: {{ wol_mode }} -# {% if wol_has_bond0 | default(false) %} -# Bond0 Detected: Yes -# Bond0 Slaves: {{ wol_bond0_slaves | join(', ') }} -# {% endif %} -# {% if wol_report_mac and wol_mac_addresses | length > 0 %} -# MAC Addresses: -# {% for iface, mac in (wol_final_interfaces | zip(wol_mac_addresses) | list) %} -# - {{ iface }}: {{ mac | default('Unable to detect') }} -# {% endfor %} -# {% endif %} +- name: Report WOL configuration + ansible.builtin.debug: + msg: | + Wake-on-LAN Configuration Summary: + =================================== + Physical Interfaces: {{ en_interfaces | join(', ') }} + WOL Mode: {{ wol_mode }} + MAC Addresses: {{ wol_mac_addresses }} + \ No newline at end of file