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
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:
@@ -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
|
#Proxmox enterprise repo
|
||||||
|
|
||||||
- name: repos | Check for Proxmox enterprise repo file
|
- name: repos | Check for Proxmox enterprise repo file
|
||||||
@@ -27,7 +31,7 @@
|
|||||||
- name: repos | Uncomment Proxmox no-subscription repo if present
|
- name: repos | Uncomment Proxmox no-subscription repo if present
|
||||||
ansible.builtin.replace:
|
ansible.builtin.replace:
|
||||||
path: /etc/apt/sources.list.d/pve-install-repo.list
|
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'
|
replace: '\1'
|
||||||
when: pve_install_repo.stat.exists
|
when: pve_install_repo.stat.exists
|
||||||
register: no_sub_uncommented
|
register: no_sub_uncommented
|
||||||
@@ -35,13 +39,13 @@
|
|||||||
- name: repos | Add Proxmox no-subscription repo if missing
|
- name: repos | Add Proxmox no-subscription repo if missing
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/apt/sources.list.d/pve-install-repo.list
|
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"
|
line: "deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription"
|
||||||
state: present
|
state: present
|
||||||
insertafter: EOF
|
insertafter: EOF
|
||||||
when: pve_install_repo.stat.exists
|
when: pve_install_repo.stat.exists
|
||||||
register: no_sub_added
|
register: no_sub_added
|
||||||
|
|
||||||
# Notify Run apt update only once if any of the above tasks changed something
|
# Notify Run apt update only once if any of the above tasks changed something
|
||||||
notify:
|
notify:
|
||||||
- Run apt update
|
- Run apt update
|
||||||
|
|||||||
Reference in New Issue
Block a user