From dbdf1908e79193ceb95701cf349e16d6f01eb012 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 06:47:31 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Simplify=20int?= =?UTF-8?q?erface=20filtering=20with=20regex=20and=20streamline=20task=20l?= =?UTF-8?q?ogic.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactored the interface filtering process by simplifying the regex pattern and optimizing the task handling to improve performance and readability. --- tasks/main.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index afc596d..b359102 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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