refactor ♻️: Refactor Proxmox repository management
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 5s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Successful in 5s
ai-reviews / Review PR (pull_request) Successful in 16s
ansible-lint / Ansible Lint (pull_request) Failing after 6s
Gitleaks Scan / gitleaks (pull_request) Successful in 4s
Markdown Lint / markdown-lint (pull_request) Successful in 5s

Introduce a variable for repo path and update regex patterns to improve code readability and maintainability.
This commit is contained in:
2026-02-08 20:00:43 +01:00
parent c139461cef
commit e680fdf162

View File

@@ -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,7 +39,7 @@
- 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