refactor ♻️: Simplify interface filtering with regex and streamline task logic.
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 8s
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 8s
Refactored the interface filtering process by simplifying the regex pattern and optimizing the task handling to improve performance and readability.
This commit is contained in:
@@ -26,16 +26,13 @@
|
|||||||
# ansible.builtin.set_fact:
|
# ansible.builtin.set_fact:
|
||||||
# en_interfaces: "{{ ansible_facts.interfaces | select('match', '^eth|^ens|^enp') | unique | list }}"
|
# en_interfaces: "{{ ansible_facts.interfaces | select('match', '^eth|^ens|^enp') | unique | list }}"
|
||||||
|
|
||||||
- name: Get interfaces starting with "en" or "eth"
|
- name: Get interfaces starting with "en or "eth"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
en_interfaces: >
|
en_interfaces: >-
|
||||||
{{
|
{{
|
||||||
ansible_facts.interfaces |
|
ansible_facts.interfaces
|
||||||
dict2items |
|
| select('match', '^(eth|en)')
|
||||||
map('attribute=item.key') |
|
| list
|
||||||
select('match', '^eth|^ens|^enp') |
|
|
||||||
unique |
|
|
||||||
list
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
- name: Display selected interfaces
|
- name: Display selected interfaces
|
||||||
|
|||||||
Reference in New Issue
Block a user