This commit refactors the Proxmox repository management tasks by adding necessary comments for better understanding. It also ensures that `apt update` is triggered whenever there are changes to the repository configuration.
51 lines
1.6 KiB
YAML
51 lines
1.6 KiB
YAML
---
|
|
|
|
- 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
|
|
ansible.builtin.stat:
|
|
path: /etc/apt/sources.list.d/pve-enterprise.list
|
|
register: pve_enterprise_repo
|
|
|
|
- name: repos | Comment out Proxmox enterprise repo lines
|
|
ansible.builtin.replace:
|
|
path: /etc/apt/sources.list.d/pve-enterprise.list
|
|
regexp: '^\s*deb\s+'
|
|
replace: '# deb '
|
|
when: pve_enterprise_repo.stat.exists
|
|
notify: Run apt update
|
|
|
|
# Proxmox no-subscription repo
|
|
|
|
- name: repos | Check for pve-install-repo.list
|
|
ansible.builtin.stat:
|
|
path: /etc/apt/sources.list.d/pve-install-repo.list
|
|
register: pve_install_repo
|
|
|
|
- name: repos | Uncomment Proxmox no-subscription repo if present
|
|
ansible.builtin.replace:
|
|
path: /etc/apt/sources.list.d/pve-install-repo.list
|
|
regexp: '^\s*#\s*(deb\s+.*pve-no-subscription)'
|
|
replace: '\1'
|
|
when: pve_install_repo.stat.exists
|
|
notify: Run apt update
|
|
|
|
- name: repos | Add Proxmox no-subscription repo if missing
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/apt/sources.list.d/pve-install-repo.list
|
|
regexp: '^\s*deb\s+.*pve-no-subscription\s*$'
|
|
line: >-
|
|
deb http://download.proxmox.com/debian/pve
|
|
{{ ansible_distribution_release }}
|
|
pve-no-subscription
|
|
state: present
|
|
insertafter: EOF
|
|
when: pve_install_repo.stat.exists
|
|
notify: Run apt update
|