commit 7043946594bbbc5bd0b78f3edd671d41bf2477b8 Author: James Pattinson Date: Thu Jun 11 16:59:26 2026 -0400 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..424bd26 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ansible/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..4958cf6 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# Proxmox nag removal playbook + +This playbook applies the same proxmox subscription nag patch pattern as the archived upstream task file: + +- upstream reference: `https://raw.githubusercontent.com/ironicbadger/ansible-role-proxmox-nag-removal/refs/heads/master/tasks/remove-nag.yml` + +Update the example hosts in `inventory.ini`, then run: + +```bash +ansible-playbook -i inventory.ini remove-proxmox-nag.yml +``` + +Notes: + +- it targets the `proxmox` inventory group +- it keeps a one-time remote backup at `proxmoxlib.js.bak` +- it also enables Ansible's `backup: true` on each replace operation +- it restarts `pveproxy` only if one of the replacements changes the file diff --git a/inventory.ini b/inventory.ini new file mode 100644 index 0000000..d79fb37 --- /dev/null +++ b/inventory.ini @@ -0,0 +1,11 @@ +[proxmox] +bonnie ansible_host=192.168.10.2 +rosie ansible_host=192.168.10.21 +pbs ansible_host=192.168.10.20 +cessna ansible_host=cessna.egfh.internal +yak ansible_host=yak.egfh.internal +pbs-egfh ansible_host=pbs.egfh.internal + +[proxmox:vars] +ansible_user=root +ansible_ssh_common_args='-F /dev/null -o ControlMaster=auto -o ControlPersist=60s' diff --git a/remove-proxmox-nag.yml b/remove-proxmox-nag.yml new file mode 100644 index 0000000..10ed449 --- /dev/null +++ b/remove-proxmox-nag.yml @@ -0,0 +1,69 @@ +--- +- name: Remove Proxmox subscription nag + hosts: proxmox + become: true + gather_facts: false + + vars: + proxmox_widget_toolkit_path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js + proxmox_widget_toolkit_backup_path: /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js.bak + + handlers: + - name: Restart web proxy + ansible.builtin.service: + name: "{{ proxmox_proxy_service }}" + state: restarted + + tasks: + - name: Gather service facts + ansible.builtin.service_facts: + + - name: Select proxy service + ansible.builtin.set_fact: + proxmox_proxy_service: >- + {{ + 'pveproxy' + if 'pveproxy.service' in ansible_facts.services + else 'proxmox-backup-proxy' + if 'proxmox-backup-proxy.service' in ansible_facts.services + else '' + }} + + - name: Fail when no supported proxy service is present + ansible.builtin.fail: + msg: "Neither pveproxy nor proxmox-backup-proxy is installed on the remote host." + when: proxmox_proxy_service == '' + + - name: Check proxmoxlib.js exists + ansible.builtin.stat: + path: "{{ proxmox_widget_toolkit_path }}" + register: proxmoxlib_stat + + - name: Fail when proxmoxlib.js is missing + ansible.builtin.fail: + msg: "{{ proxmox_widget_toolkit_path }} was not found on the remote host." + when: not proxmoxlib_stat.stat.exists + + - name: Preserve original proxmoxlib.js once + ansible.builtin.copy: + src: "{{ proxmox_widget_toolkit_path }}" + dest: "{{ proxmox_widget_toolkit_backup_path }}" + remote_src: true + force: false + mode: preserve + + - name: Disable the subscription status check in proxmoxlib.js + ansible.builtin.replace: + path: "{{ proxmox_widget_toolkit_path }}" + regexp: "res\\.data\\.status\\.toLowerCase\\(\\) !== 'active'" + replace: "false" + backup: true + notify: Restart web proxy + + - name: Disable the legacy subscription status check in proxmoxlib.js + ansible.builtin.replace: + path: "{{ proxmox_widget_toolkit_path }}" + regexp: "data\\.status !== 'Active'" + replace: "false" + backup: true + notify: Restart web proxy