refactor ♻️: Refactor task to extract Supports Wake-on per interface using set_fact and loop.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 9s

This refactoring extracts the logic for handling Wake-on settings per network interface into a reusable task. It uses `set_fact` and loops to simplify the configuration process and improve readability.
This commit is contained in:
2025-12-26 08:04:06 +01:00
parent c3aa02447c
commit c35ff62880

View File

@@ -56,10 +56,22 @@
ansible.builtin.debug:
var: wol_status
- name: Extract Supports Wake-on per interface
ansible.builtin.set_fact:
supports_wake_on: >-
{{
supports_wake_on | default({}) |
combine({
item.item:
(item.stdout | regex_search('Supports Wake-on:\\s*(\\S+)', '\\1'))
})
}}
loop: "{{ wol_status.results }}"
when: item.stdout is defined
- name: Extract Supports Wake-on value
set_fact:
supports_wake_on: "{{ wol_status.results | regex_search('(?m)^\\s*Supports Wake-on:\\s*(\\S+)', '\\1') }}"
# - name: Extract Supports Wake-on value
# set_fact:
# supports_wake_on: "{{ wol_status.results | regex_search('(?m)^\\s*Supports Wake-on:\\s*(\\S+)', '\\1') }}"
- name: Show Supports Wake-on value
debug: