From b42e72a835b84f6cababb24d4643c16e271b07a7 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2026 18:07:22 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20Pro?= =?UTF-8?q?xmox=20repo=20management=20tasks,=20add=20comments,=20and=20ens?= =?UTF-8?q?ure=20apt=20update=20is=20triggered=20on=20changes.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tasks/repos.yml | 25 +++++++++++-------------- templates/logrotate-pve.j2 | 13 ------------- 2 files changed, 11 insertions(+), 27 deletions(-) delete mode 100644 templates/logrotate-pve.j2 diff --git a/tasks/repos.yml b/tasks/repos.yml index 0a619a2..bf1af82 100644 --- a/tasks/repos.yml +++ b/tasks/repos.yml @@ -16,10 +16,10 @@ - name: repos | Comment out Proxmox enterprise repo lines ansible.builtin.replace: path: /etc/apt/sources.list.d/pve-enterprise.list - regexp: '^(deb\s+)' - replace: '# \1' + regexp: '^\s*deb\s+' + replace: '# deb ' when: pve_enterprise_repo.stat.exists - register: enterprise_changed + notify: Run apt update # Proxmox no-subscription repo @@ -31,23 +31,20 @@ - 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+{{ repo_path }}s+{{ ansible_distribution_release }}\s+pve-no-subscription)' + regexp: '^\s*#\s*(deb\s+.*pve-no-subscription)' replace: '\1' when: pve_install_repo.stat.exists - register: no_sub_uncommented + 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: '^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" + 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 - register: no_sub_added - - # Notify Run apt update only once if any of the above tasks changed something - notify: - - Run apt update - # Trigger only if any changes occurred - when: enterprise_changed.changed or no_sub_uncommented.changed or no_sub_added.changed + notify: Run apt update diff --git a/templates/logrotate-pve.j2 b/templates/logrotate-pve.j2 deleted file mode 100644 index 6d78e57..0000000 --- a/templates/logrotate-pve.j2 +++ /dev/null @@ -1,13 +0,0 @@ -/var/log/pve/*.log /var/log/pve/tasks/*.log { - daily - rotate {{ proxmox_logrotate_rotate }} - compress - missingok - notifempty - maxsize {{ proxmox_logrotate_maxsize }} - create 0640 root adm - sharedscripts - postrotate - systemctl reload rsyslog >/dev/null 2>&1 || true - endscript -}