From b42e72a835b84f6cababb24d4643c16e271b07a7 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2026 18:07:22 +0100 Subject: [PATCH 1/4] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20Proxmox=20repo=20management=20tasks,=20add=20comments,=20and?= =?UTF-8?q?=20ensure=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 -} -- 2.49.1 From 75cff9590d5c225b1b3a772570ae97dc0a4b89c1 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2026 18:12:13 +0100 Subject: [PATCH 2/4] =?UTF-8?q?feat=20=E2=9C=A8:=20Add=20new=20script=20pv?= =?UTF-8?q?e-remove-nag.sh=20for=20removing=20Nag=20messages=20in=20PVE=20?= =?UTF-8?q?UIs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit introduces a new script `pve-remove-nag.sh` designed to remove nag messages from both the Proxmox VE web and mobile user interfaces. The script is refactored to improve installation process, and the UI patching logic has been temporarily commented out for further refinement. --- files/pve-remove-nag.sh | 46 +++++++++++++++++++++++++++++++++++++ tasks/subscription.yml | 51 ++--------------------------------------- 2 files changed, 48 insertions(+), 49 deletions(-) create mode 100644 files/pve-remove-nag.sh diff --git a/files/pve-remove-nag.sh b/files/pve-remove-nag.sh new file mode 100644 index 0000000..519e3b2 --- /dev/null +++ b/files/pve-remove-nag.sh @@ -0,0 +1,46 @@ +#!/bin/sh +# source: https://github.com/community-scripts/ProxmoxVE/blob/main/tools/pve/post-pve-install.sh +# Commit c464b95 + +WEB_JS=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js +if [ -s "$WEB_JS" ] && ! grep -q NoMoreNagging "$WEB_JS"; then + echo "Patching Web UI nag..." + sed -i \ + -e "/data\.status/ s/!//" \ + -e "/data\.status/ s/active/NoMoreNagging/" \ + "$WEB_JS" +fi + +MOBILE_TPL=/usr/share/pve-yew-mobile-gui/index.html.tpl +MARKER="" +if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then + echo "Patching Mobile UI nag..." + cat <<'EOF' >> "$MOBILE_TPL" + + +EOF +fi diff --git a/tasks/subscription.yml b/tasks/subscription.yml index ba8750e..9ad5f35 100644 --- a/tasks/subscription.yml +++ b/tasks/subscription.yml @@ -12,60 +12,13 @@ path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js register: proxmoxlib_js -- name: Install pve-remove-nag script +- name: subscription | Install pve-remove-nag script ansible.builtin.copy: + src: pve-remove-nag.sh dest: /usr/local/bin/pve-remove-nag.sh owner: root group: root mode: "0755" - content: | - #!/bin/sh - # source: https://github.com/community-scripts/ProxmoxVE/blob/main/tools/pve/post-pve-install.sh - # Commit c464b95 - WEB_JS=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js - if [ -s "$WEB_JS" ] && ! grep -q NoMoreNagging "$WEB_JS"; then - echo "Patching Web UI nag..." - sed -i -e "/data\.status/ s/!//" -e "/data\.status/ s/active/NoMoreNagging/" "$WEB_JS" - fi - - MOBILE_TPL=/usr/share/pve-yew-mobile-gui/index.html.tpl - MARKER="" - if [ -f "$MOBILE_TPL" ] && ! grep -q "$MARKER" "$MOBILE_TPL"; then - echo "Patching Mobile UI nag..." - printf "%s\n" \ - "$MARKER" \ - "" \ - "" >> "$MOBILE_TPL" - fi when: proxmoxlib_js.stat.exists - name: Install APT post-invoke hook for nag removal -- 2.49.1 From abdba530538e3e3579aea8bc3e8723283e4d585e Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2026 18:20:19 +0100 Subject: [PATCH 3/4] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20logrotate=20tasks=20for=20better=20readability=20and=20consi?= =?UTF-8?q?stency=20-=20Rename=20'logrotate=20reload'=20task=20to=20'Logro?= =?UTF-8?q?tate=20reload'=20-=20Refactor=20task=20names=20in=20`subscripti?= =?UTF-8?q?on.yml`=20for=20better=20organization=20and=20clarity?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit refactors the logrotate tasks by renaming them for better readability and consistency, and refactoring task names in `subscription.yml` for improved organization and clarity. --- handlers/main.yml | 2 +- tasks/logrotate.yml | 48 +++++++++++++++++++++--------------------- tasks/subscription.yml | 4 ++-- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index b5cff37..e48a179 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -15,6 +15,6 @@ ansible.builtin.systemd_service: daemon_reexec: true -- name: logrotate reload +- name: Logrotate reload ansible.builtin.command: logrotate /etc/logrotate.conf changed_when: false diff --git a/tasks/logrotate.yml b/tasks/logrotate.yml index aa385a8..1db9a31 100644 --- a/tasks/logrotate.yml +++ b/tasks/logrotate.yml @@ -13,98 +13,98 @@ block: - - name: Check if {{ item }} exists + - name: logrotate | Check if {{ item }} exists ansible.builtin.stat: path: "{{ item }}" register: logrotate_file - - name: Configure {{ item }} + - name: logrotate | Configure {{ item }} + when: logrotate_file.stat.exists block: - - name: Backup {{ item }} once + - name: logrotate | Backup {{ item }} once ansible.builtin.copy: src: "{{ item }}" dest: "{{ item }}.original" + owner: root + group: root remote_src: true args: creates: "{{ item }}.original" - - name: Ensure daily rotation + - name: logrotate | Ensure daily rotation ansible.builtin.replace: path: "{{ item }}" regexp: '^\s*weekly' replace: 'daily' - notify: logrotate reload + notify: Logrotate reload - - name: Set rotate (number of retained logs) + - name: logrotate | Set rotate (number of retained logs) ansible.builtin.lineinfile: path: "{{ item }}" regexp: '^(\s*rotate\s+).*' line: ' rotate {{ proxmox_logrotate_rotate }}' state: present insertafter: '^\s*daily' - notify: logrotate reload + notify: Logrotate reload - - name: Ensure maxsize is set + - name: logrotate | Ensure maxsize is set ansible.builtin.lineinfile: path: "{{ item }}" regexp: '^(\s*maxsize\s+).*' line: ' maxsize {{ proxmox_logrotate_maxsize }}' state: present insertafter: '^\s*rotate' - notify: logrotate reload + notify: Logrotate reload - - name: Ensure Compress + - name: logrotate | Ensure Compress ansible.builtin.lineinfile: path: "{{ item }}" regexp: '^\s*compress\b' line: ' compress' state: present insertafter: '^\s*maxsize' - notify: logrotate reload + notify: Logrotate reload - - name: Ensure delaycompress + - name: logrotate | Ensure delaycompress ansible.builtin.lineinfile: path: "{{ item }}" regexp: '^\s*delaycompress\b' line: ' delaycompress' state: present insertafter: '^\s*compress' - notify: logrotate reload - - when: logrotate_file.stat.exists - + notify: Logrotate reload # only for logrotate.conf -- name: Uncomment dateext if commented +- name: logrotate | Uncomment dateext if commented ansible.builtin.replace: path: /etc/logrotate.conf regexp: '^\s*#\s*(dateext)\b' replace: '\1' - notify: logrotate reload + notify: Logrotate reload -- name: Uncomment compress if commented +- name: logrotate | Uncomment compress if commented ansible.builtin.replace: path: /etc/logrotate.conf regexp: '^\s*#\s*(compress)\b' replace: '\1' - notify: logrotate reload + notify: Logrotate reload -- name: Ensure missingok is present +- name: logrotate | Ensure missingok is present ansible.builtin.lineinfile: path: /etc/logrotate.conf regexp: '^\s*missingok\b' line: 'missingok' state: present insertafter: EOF - notify: logrotate reload + notify: Logrotate reload -- name: Ensure notifempty is present +- name: logrotate | Ensure notifempty is present ansible.builtin.lineinfile: path: /etc/logrotate.conf regexp: '^\s*notifempty\b' line: 'notifempty' state: present insertafter: EOF - notify: logrotate reload + notify: Logrotate reload diff --git a/tasks/subscription.yml b/tasks/subscription.yml index 9ad5f35..83c0dbf 100644 --- a/tasks/subscription.yml +++ b/tasks/subscription.yml @@ -1,5 +1,5 @@ --- -- name: Ensure /usr/local/bin exists +- name: subscription | Ensure /usr/local/bin exists ansible.builtin.file: path: /usr/local/bin state: directory @@ -21,7 +21,7 @@ mode: "0755" when: proxmoxlib_js.stat.exists -- name: Install APT post-invoke hook for nag removal +- name: subscription | Install APT post-invoke hook for nag removal ansible.builtin.copy: dest: /etc/apt/apt.conf.d/no-nag-script owner: root -- 2.49.1 From 3e6e1cb893133e7ec11ea839cb4681beb94ccf85 Mon Sep 17 00:00:00 2001 From: Jose Date: Mon, 9 Feb 2026 18:23:01 +0100 Subject: [PATCH 4/4] =?UTF-8?q?fix=20=F0=9F=90=9B:=20Fix=20typo=20and=20ad?= =?UTF-8?q?d=20file=20permission=20in=20logrotate.yml=20task?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a typo in the logrotate configuration file and adds necessary file permissions to ensure proper rotation of log files. --- tasks/logrotate.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tasks/logrotate.yml b/tasks/logrotate.yml index 1db9a31..355835f 100644 --- a/tasks/logrotate.yml +++ b/tasks/logrotate.yml @@ -13,7 +13,7 @@ block: - - name: logrotate | Check if {{ item }} exists + - name: logrotate | Check if exists {{ item }} ansible.builtin.stat: path: "{{ item }}" register: logrotate_file @@ -22,12 +22,13 @@ when: logrotate_file.stat.exists block: - - name: logrotate | Backup {{ item }} once + - name: logrotate | Backup once {{ item }} ansible.builtin.copy: src: "{{ item }}" dest: "{{ item }}.original" owner: root group: root + mode: "0644" remote_src: true args: creates: "{{ item }}.original" -- 2.49.1