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
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:
@@ -56,10 +56,22 @@
|
|||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: wol_status
|
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
|
# - name: Extract Supports Wake-on value
|
||||||
set_fact:
|
# set_fact:
|
||||||
supports_wake_on: "{{ wol_status.results | regex_search('(?m)^\\s*Supports Wake-on:\\s*(\\S+)', '\\1') }}"
|
# supports_wake_on: "{{ wol_status.results | regex_search('(?m)^\\s*Supports Wake-on:\\s*(\\S+)', '\\1') }}"
|
||||||
|
|
||||||
- name: Show Supports Wake-on value
|
- name: Show Supports Wake-on value
|
||||||
debug:
|
debug:
|
||||||
|
|||||||
Reference in New Issue
Block a user