From 90da27fe8eb08efa1e3fa366148bae42f1c85ccd Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 12:19:22 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20tas?= =?UTF-8?q?k=20to=20dynamically=20append=20MAC=20addresses=20and=20update?= =?UTF-8?q?=20debug=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring involves updating the task logic to dynamically append MAC addresses to relevant data structures. Additionally, it includes an update to the debug message format for better clarity and consistency. --- tasks/main.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 730a67b..fe4a170 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -74,17 +74,16 @@ - wol_mode == 'd' - wol_mode not in item.1.stdout +# ... (everything before this stays unchanged) + - name: Get MAC addresses ansible.builtin.set_fact: wol_mac_addresses: >- - {{ - en_interfaces - | map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}), 'macaddress') - | list - }} + {{ wol_mac_addresses | default([]) + [ hostvars[inventory_hostname]['ansible_' ~ item].macaddress ] }} loop: "{{ en_interfaces }}" when: en_interfaces | length > 0 +# ... (any other tasks between them remain unchanged) - name: Report WOL configuration ansible.builtin.debug: @@ -93,5 +92,4 @@ =================================== Physical Interfaces: {{ en_interfaces | join(', ') }} WOL Mode: {{ wol_mode }} - MAC Addresses: {{ wol_mac_addresses }} - \ No newline at end of file + MAC Addresses: {{ wol_mac_addresses | join(', ') }} \ No newline at end of file