refactor ♻️: Simplify Wake-on-LAN task loop variables and conditions
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s
Refactored the Wake-on-LAN task to use more concise and readable loop variables and conditions, improving code clarity without altering its functionality.
This commit is contained in:
@@ -57,20 +57,13 @@
|
||||
when: en_interfaces | length > 0
|
||||
|
||||
- name: Enable Wake-on-LAN (magic packet) when supported
|
||||
ansible.builtin.command: "ethtool -s {{ item.interface }} wol g"
|
||||
ansible.builtin.command: "ethtool -s {{ item.0 }} 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:
|
||||
- "'g' not in wol_enabled_result.stdout"
|
||||
- "'g' in wol_supported_result.stdout"
|
||||
- "'g' not in item.1.stdout"
|
||||
- "'g' in item.2.stdout"
|
||||
|
||||
|
||||
# # ============================================================
|
||||
|
||||
Reference in New Issue
Block a user