refactor ♻️: Refactor legacy and minified proxmoxlib.js patching logic to use handlers
Some checks failed
ansible-lint / Ansible Lint (push) Failing after 12s
Gitleaks Scan / gitleaks (push) Successful in 5s
Markdown Lint / markdown-lint (push) Successful in 5s

no-handler::Tasks that run when changed should likely be handlers

This commit refactors the existing logic for patching legacy and minified proxmoxlib.js files, improving readability and maintainability. It also adds new handlers to store checksums and restart pveproxy.
This commit is contained in:
2026-02-08 07:07:23 +01:00
parent afc80dc57d
commit 12b1b87af1
2 changed files with 76 additions and 66 deletions

View File

@@ -14,3 +14,62 @@
- name: Reload systemd
ansible.builtin.systemd_service:
daemon_reexec: true
- name: patch legacy proxmoxlib.js
block:
- name: Patch legacy proxmoxlib.js
ansible.builtin.replace:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
regexp: "if \\(data.status !== 'Active'\\)"
replace: "if (false)"
register: patch_legacy
failed_when: patch_legacy.matched == 0
notify: Restart pveproxy
- name: Re-stat proxmoxlib.js
ansible.builtin.stat:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
checksum_algorithm: sha256
register: proxmoxlib_js_after
- name: Store patched checksum (legacy)
ansible.builtin.copy:
dest: /var/lib/proxmox-nag-patch/proxmoxlib.js.sha256
owner: root
group: root
mode: "0644"
content: "{{ proxmoxlib_js_after.stat.checksum }}\n"
- name: Restart pveproxy
systemd:
name: pveproxy
state: restarted
- name: patch minified proxmoxlib.js
block:
- name: Patch minified proxmoxlib.min.js
ansible.builtin.replace:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js
regexp: "data.status!=='Active'"
replace: "false"
register: patch_minified
failed_when: patch_minified.matched == 0
- name: Re-stat proxmoxlib.min.js
ansible.builtin.stat:
path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.min.js
checksum_algorithm: sha256
register: proxmoxlib_min_after
- name: Store patched checksum (minified)
ansible.builtin.copy:
dest: /var/lib/proxmox-nag-patch/proxmoxlib.min.js.sha256
owner: root
group: root
mode: "0644"
content: "{{ proxmoxlib_min_after.stat.checksum }}\n"
- name: Restart pveproxy
systemd:
name: pveproxy
state: restarted