refactor ♻️: Refactor Proxmox repository management #5
@@ -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'
|
||||
|
gitea-actions
commented
[Lines 34-35] [Score: 2] Use a more descriptive regex pattern for better readability. For example, [Lines 34-35] [Score: 2] Use a more descriptive regex pattern for better readability. For example, `^#\s*deb\s+{{ repo_path }}\s+[a-zA-Z]+s+\s+pve-no-subscription`
|
||||
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"
|
||||
|
gitea-actions
commented
[Lines 42-43] [Score: 2] Use a more descriptive regex pattern for better readability. For example, [Lines 42-43] [Score: 2] Use a more descriptive regex pattern for better readability. For example, `^deb\s*{{ repo_path }}\s+[a-zA-Z]+s+\s+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
|
||||
|
||||
Reference in New Issue
Block a user
[Lines 6-8] [Score: 2] Const declarations are generally preferred for variable declaration. It makes the code more explicit and easier to understand, especially when dealing with complex data structures or multiple variables with the same type. Here,
const repo_pathcould be used instead ofvar.