refactor ♻️: Refactor Wake-on-LAN task to use zip for parallel processing of interfaces
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 10s
This refactoring improves the efficiency of the Wake-on-LAN task by utilizing the `zip` function to process multiple network interfaces in parallel. This change enhances performance and allows WOL functionality when supported on multiple interfaces.
This commit is contained in:
@@ -57,11 +57,20 @@
|
|||||||
when: en_interfaces | length > 0
|
when: en_interfaces | length > 0
|
||||||
|
|
||||||
- name: Enable Wake-on-LAN (magic packet) when supported
|
- name: Enable Wake-on-LAN (magic packet) when supported
|
||||||
ansible.builtin.command: "ethtool -s {{ item }} wol g"
|
ansible.builtin.command: "ethtool -s {{ item.interface }} wol g"
|
||||||
|
loop: "{{ en_interfaces | zip(wol_enabled.results, wol_supported.results) | list }}"
|
||||||
|
loop_control:
|
||||||
|
label: "{{ item.0 }}"
|
||||||
|
vars:
|
||||||
|
# item.0 = interface
|
||||||
|
# item.1 = wol_enabled result
|
||||||
|
# item.2 = wol_supported result
|
||||||
|
interface: "{{ item.0 }}"
|
||||||
|
wol_enabled_result: "{{ item.1 }}"
|
||||||
|
wol_supported_result: "{{ item.2 }}"
|
||||||
when:
|
when:
|
||||||
- "'g' not in wol_enabled.results[loop.index0].stdout"
|
- "'g' not in wol_enabled_result.stdout"
|
||||||
- "'g' in wol_supported.results[loop.index0].stdout"
|
- "'g' in wol_supported_result.stdout"
|
||||||
loop: "{{ en_interfaces }}"
|
|
||||||
|
|
||||||
|
|
||||||
# # ============================================================
|
# # ============================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user