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 == 'd'
|
||||||
- wol_mode not in item.1.stdout
|
- wol_mode not in item.1.stdout
|
||||||
|
|
||||||
# # ============================================================
|
- name: Get MAC addresses
|
||||||
# # Verification & Reporting
|
ansible.builtin.set_fact:
|
||||||
# # ============================================================
|
wol_mac_addresses: >-
|
||||||
# - name: Verify Wake-on-LAN status
|
{{
|
||||||
# ansible.builtin.command: "ethtool {{ item }}"
|
en_interfaces
|
||||||
# register: wol_status
|
| map('extract', hostvars[inventory_hostname]['ansible_' ~ item] | default({}), 'macaddress')
|
||||||
# changed_when: false
|
| list
|
||||||
# loop: "{{ wol_final_interfaces }}"
|
}}
|
||||||
# loop_control:
|
|
||||||
# label: "{{ item }}"
|
|
||||||
# when: wol_verify
|
|
||||||
|
|
||||||
# - name: Display WOL status per interface
|
- name: Report WOL configuration
|
||||||
# ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
# msg: >
|
msg: |
|
||||||
# Interface {{ item.item }} WOL Status:
|
Wake-on-LAN Configuration Summary:
|
||||||
# {{ item.stdout_lines | select('search', 'Wake-on:') | first | default('Status Unknown') }}
|
===================================
|
||||||
# loop: "{{ wol_status.results | default([]) }}"
|
Physical Interfaces: {{ en_interfaces | join(', ') }}
|
||||||
# loop_control:
|
WOL Mode: {{ wol_mode }}
|
||||||
# label: "{{ item.item }}"
|
MAC Addresses: {{ wol_mac_addresses }}
|
||||||
# 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 %}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user