From f33d1563b750d6607b55417a60422fe8a9c6001c Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 19:46:25 +0100 Subject: [PATCH 1/5] =?UTF-8?q?style=20=F0=9F=92=8E:=20Remove=20unnecessar?= =?UTF-8?q?y=20blank=20line=20from=20logrotate.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleaned up the configuration file by removing an extra blank line that was not necessary. --- handlers/main.yml | 2 +- tasks/logrotate.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/handlers/main.yml b/handlers/main.yml index efc3492..b5cff37 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -17,4 +17,4 @@ - name: logrotate reload ansible.builtin.command: logrotate /etc/logrotate.conf - changed_when: false \ No newline at end of file + changed_when: false diff --git a/tasks/logrotate.yml b/tasks/logrotate.yml index cfc8aba..aa385a8 100644 --- a/tasks/logrotate.yml +++ b/tasks/logrotate.yml @@ -1,7 +1,7 @@ --- - name: logrotate | Configure all main Proxmox logs - + vars: proxmox_logrotate_files: - /etc/logrotate.conf -- 2.49.1 From c139461cef689f960a0be970b9fee023263400fb Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 19:49:12 +0100 Subject: [PATCH 2/5] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20Proxmox=20repository=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conditionally comment out and uncomment repositories, ensuring `apt update` is run only when necessary. --- tasks/repos.yml | 63 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/tasks/repos.yml b/tasks/repos.yml index 38fa936..2f5321e 100644 --- a/tasks/repos.yml +++ b/tasks/repos.yml @@ -1,18 +1,49 @@ --- -- 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' - when: ansible.builtin.stat(path='/etc/apt/sources.list.d/pve-enterprise.list').stat.exists - notify: apt update +- name: repos | Manage Proxmox repositories + block: -- name: repos | Enable Proxmox no-subscription repo - ansible.builtin.copy: - dest: /etc/apt/sources.list.d/pve-no-subscription.list - owner: root - group: root - mode: "0644" - content: | - deb http://download.proxmox.com/debian/pve {{ ansible_distribution_release }} pve-no-subscription - notify: apt update + #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: '^(deb\s+)' + replace: '# \1' + when: pve_enterprise_repo.stat.exists + register: enterprise_changed + + #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*(deb\s+http://download\.proxmox\.com/debian/pve\s+{{ ansible_distribution_release }}\s+pve-no-subscription)' + replace: '\1' + when: pve_install_repo.stat.exists + register: no_sub_uncommented + + - 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$' + 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 -- 2.49.1 From e680fdf162b3647a9c409907ce75e30c5c5a2ec6 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 20:00:43 +0100 Subject: [PATCH 3/5] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20Proxmox=20repository=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a variable for repo path and update regex patterns to improve code readability and maintainability. --- tasks/repos.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tasks/repos.yml b/tasks/repos.yml index 2f5321e..c97f4ac 100644 --- a/tasks/repos.yml +++ b/tasks/repos.yml @@ -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' 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" 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 -- 2.49.1 From f96b3da66ec12402a5e89e751b5a60243538a997 Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 20:02:25 +0100 Subject: [PATCH 4/5] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor?= =?UTF-8?q?=20variable=20and=20comment=20formatting=20in=20`repos.yml`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Updated variable names and comments for better readability and consistency. --- tasks/repos.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tasks/repos.yml b/tasks/repos.yml index c97f4ac..0a619a2 100644 --- a/tasks/repos.yml +++ b/tasks/repos.yml @@ -2,11 +2,11 @@ - name: repos | Manage Proxmox repositories vars: - repo_path: - - http://download\.proxmox\.com/debian/pve\ + repo_path: + - http://download\.proxmox\.com/debian/pve\ block: - #Proxmox enterprise repo + # Proxmox enterprise repo - name: repos | Check for Proxmox enterprise repo file ansible.builtin.stat: @@ -21,7 +21,7 @@ when: pve_enterprise_repo.stat.exists register: enterprise_changed - #Proxmox no-subscription repo + # Proxmox no-subscription repo - name: repos | Check for pve-install-repo.list ansible.builtin.stat: -- 2.49.1 From 85e021c864151aa20ede19152e25ca03cb31777e Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 8 Feb 2026 20:03:53 +0100 Subject: [PATCH 5/5] =?UTF-8?q?chore=20=F0=9F=93=A6:=20Add=20setup=20scrip?= =?UTF-8?q?ts=20for=20`/usr/local/bin`=20and=20APT=20post-invoke=20hook?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit includes the installation of `pve-remove-nag.sh` script, checks for legacy `proxmoxlib.js`, and ensures that `/usr/local/bin` exists. Additionally, it sets up an APT post-invoke hook to run necessary tasks after package installations. --- tasks/subscription.yml | 106 +++++++++++++++++++++++++++-------------- 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/tasks/subscription.yml b/tasks/subscription.yml index e0441f6..6a24492 100644 --- a/tasks/subscription.yml +++ b/tasks/subscription.yml @@ -1,12 +1,81 @@ --- -- name: subscription | Ensure nag patch state directory exists +- name: Ensure /usr/local/bin exists ansible.builtin.file: - path: /var/lib/proxmox-nag-patch + path: /usr/local/bin state: directory owner: root group: root mode: "0755" +- name: subscription | Check for legacy proxmoxlib.js + ansible.builtin.stat: + path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js + register: proxmoxlib_js + +- name: Install pve-remove-nag script + ansible.builtin.copy: + 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 + ansible.builtin.copy: + dest: /etc/apt/apt.conf.d/no-nag-script + owner: root + group: root + mode: "0644" + content: | + DPkg::Post-Invoke { "/usr/local/bin/pve-remove-nag.sh"; }; + ############################ # Legacy proxmoxlib.js ############################ @@ -14,16 +83,8 @@ - name: subscription | Check for legacy proxmoxlib.js ansible.builtin.stat: path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js - checksum_algorithm: sha256 register: proxmoxlib_js -- name: subscription | Read stored checksum (legacy) - ansible.builtin.slurp: - src: /var/lib/proxmox-nag-patch/proxmoxlib.js.sha256 - register: proxmoxlib_js_checksum_stored - when: proxmoxlib_js.stat.exists - failed_when: false - - name: subscription | Trigger legacy nag patch if needed ansible.builtin.meta: flush_handlers when: @@ -33,28 +94,3 @@ != (proxmoxlib_js_checksum_stored.content | b64decode | trim) notify: Ppatch legacy proxmoxlib.js -############################ -# Minified proxmoxlib.min.js (VE 8/9) -############################ - -- name: subscription | Check for minified proxmoxlib.min.js (VE 8/9) - ansible.builtin.stat: - path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js - checksum_algorithm: sha256 - register: proxmoxlib_min_js - -- name: subscription | Read stored checksum (minified) - ansible.builtin.slurp: - src: /var/lib/proxmox-nag-patch/proxmoxlib.min.js.sha256 - register: proxmoxlib_min_checksum_stored - when: proxmoxlib_min_js.stat.exists - failed_when: false - -- name: subscription | Trigger minified nag patch if needed - ansible.builtin.meta: flush_handlers - when: - - proxmoxlib_min_js.stat.exists - - proxmoxlib_min_checksum_stored.content is not defined - or proxmoxlib_min_js.stat.checksum - != (proxmoxlib_min_checksum_stored.content | b64decode | trim) - notify: Patch minified proxmoxlib.js -- 2.49.1