refactor ♻️: Simplify interface filtering with regex and streamline task logic.
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:
2025-12-26 06:47:31 +01:00
parent 756e39a498
commit dbdf1908e7

View File

@@ -26,16 +26,13 @@
# ansible.builtin.set_fact:
# 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:
en_interfaces: >
en_interfaces: >-
{{
ansible_facts.interfaces |
dict2items |
map('attribute=item.key') |
select('match', '^eth|^ens|^enp') |
unique |
list
ansible_facts.interfaces
| select('match', '^(eth|en)')
| list
}}
- name: Display selected interfaces