refactor ♻️: Refactor task to dynamically append MAC addresses and update debug message
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
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.
This commit is contained in:
@@ -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 }}
|
||||
|
||||
MAC Addresses: {{ wol_mac_addresses | join(', ') }}
|
||||
Reference in New Issue
Block a user