refactor ♻️: Simplify and update task reporting
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the task reporting process to improve clarity and efficiency, updating the code logic while maintaining external behavior.
This commit is contained in:
@@ -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: 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 }}
|
||||
|
||||
# - 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 %}
|
||||
|
||||
Reference in New Issue
Block a user