From e680fdf162b3647a9c409907ce75e30c5c5a2ec6 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 20:00:43 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20Pro?= =?UTF-8?q?xmox=20repository=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a variable for repo path and update regex patterns to improve code readability and maintainability. --- tasks/repos.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tasks/repos.yml b/tasks/repos.yml index 2f5321e..c97f4ac 100644 --- a/tasks/repos.yml +++ b/tasks/repos.yml @@ -1,7 +1,11 @@ --- -- name: repos | Manage Proxmox repositories - block: +- name: repos | Manage Proxmox repositories + vars: + repo_path: + - http://download\.proxmox\.com/debian/pve\ + + block: #Proxmox enterprise repo - name: repos | Check for Proxmox enterprise repo file @@ -27,7 +31,7 @@ - name: repos | Uncomment Proxmox no-subscription repo if present ansible.builtin.replace: path: /etc/apt/sources.list.d/pve-install-repo.list - regexp: '^#\s*(deb\s+http://download\.proxmox\.com/debian/pve\s+{{ ansible_distribution_release }}\s+pve-no-subscription)' + regexp: '^#\s*(deb\s+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription)' replace: '\1' when: pve_install_repo.stat.exists register: no_sub_uncommented @@ -35,13 +39,13 @@ - name: repos | Add Proxmox no-subscription repo if missing ansible.builtin.lineinfile: path: /etc/apt/sources.list.d/pve-install-repo.list - regexp: '^deb\s+http://download\.proxmox\.com/debian/pve\s+{{ ansible_distribution_release }}\s+pve-no-subscription$' + regexp: '^deb\s+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription$' line: "deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription" state: present insertafter: EOF when: pve_install_repo.stat.exists register: no_sub_added - + # Notify Run apt update only once if any of the above tasks changed something notify: - Run apt update