refactor ♻️: Refactor interface selection and add loop for WOL capability validation
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s
All checks were successful
ansible-lint / Ansible Lint (push) Successful in 12s
This refactoring improves the interface selection process and adds a loop to validate WOL (Wake-On-LAN) capabilities, enhancing system reliability and user experience.
This commit is contained in:
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
- name: Get interfaces starting with "en"
|
- name: Get interfaces starting with "en"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
en_interfaces: "{{ ansible_facts.interfaces | select('match', '^en') | list }}"
|
en_interfaces: "{{ ansible_facts.interfaces | select('match', '^eth|^ens|^enp') | unique | list }}"
|
||||||
|
|
||||||
- name: Display WOL interface
|
- name: Display WOL interface
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
@@ -32,10 +32,13 @@
|
|||||||
{{ en_interfaces }}
|
{{ en_interfaces }}
|
||||||
|
|
||||||
- name: Validate WOL capability using ethtool for detected interfaces
|
- name: Validate WOL capability using ethtool for detected interfaces
|
||||||
ansible.builtin.command: "ethtool {{ en_interfaces }}"
|
ansible.builtin.command: "ethtool {{ item }}"
|
||||||
register: wol_capabilities_check
|
register: wol_capabilities_check
|
||||||
changed_when: false
|
changed_when: false
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
loop: "{{ en_interfaces }}"
|
||||||
|
|
||||||
|
when: en_interfaces | length > 0
|
||||||
|
|
||||||
- name: Display ethtool output for detected interfaces
|
- name: Display ethtool output for detected interfaces
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user