The *-update.yml playbooks hard-coded the pre-migration VMIDs, so after cutover the "safety backup" ran against the stopped OLD container. Now the VMID comes from homelab_services['<svc>'].vmid. Also removes `--prune-backups keep-all=1` from the vzdump calls: retention is PBS's job (prune-pbs), and the client-side flag needed Datastore.Modify/Prune the ansible@pve token does not have, which made vzdump print "Backup ... failed" and exit non-zero after a successful upload. gitea-update.yml additionally splits the offsite backup (hosts: gitea) from its audit (hosts: cloud-pc), matching the profile move into the container. pve-*.yml imports pass pve_provisioning_enabled: false so the runtime update path never re-enters container creation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012uoq5AVK8mkBgg83Mq6o5V
103 lines
3.0 KiB
YAML
103 lines
3.0 KiB
YAML
---
|
|
- name: Create and verify Vaultwarden backup before update
|
|
hosts: vaultwarden
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Create a fresh Vaultwarden offsite backup
|
|
ansible.builtin.command:
|
|
argv:
|
|
- systemctl
|
|
- start
|
|
- --wait
|
|
- homelab-restic-offsite-vaultwarden.service
|
|
changed_when: true
|
|
|
|
- name: Run Vaultwarden offsite backup audit
|
|
ansible.builtin.command:
|
|
argv:
|
|
- systemctl
|
|
- start
|
|
- --wait
|
|
- homelab-backup-audit-vaultwarden.service
|
|
changed_when: true
|
|
|
|
- name: Create and verify Vaultwarden PBS backup before update
|
|
hosts: mini-pc
|
|
gather_facts: false
|
|
vars:
|
|
vaultwarden_vmid: "{{ homelab_services['vaultwarden'].vmid }}"
|
|
tasks:
|
|
- name: Read existing Vaultwarden VMID configuration
|
|
ansible.builtin.command: "pct config {{ vaultwarden_vmid }}"
|
|
register: vaultwarden_existing_vmid
|
|
changed_when: false
|
|
|
|
- name: Refuse to modify a foreign Vaultwarden VMID
|
|
ansible.builtin.assert:
|
|
that:
|
|
- vaultwarden_existing_vmid.rc == 0
|
|
- vaultwarden_existing_hostname == 'vaultwarden'
|
|
fail_msg: >-
|
|
VMID {{ vaultwarden_vmid }} from the service registry is not the
|
|
Vaultwarden container.
|
|
vars:
|
|
vaultwarden_existing_hostname: >-
|
|
{{ vaultwarden_existing_vmid.stdout_lines
|
|
| select('match', '^hostname: ')
|
|
| map('regex_replace', '^hostname: ', '')
|
|
| first
|
|
| default('') }}
|
|
|
|
- name: Check for active Proxmox backup before Vaultwarden PBS backup
|
|
ansible.builtin.command: pgrep -x vzdump
|
|
register: vaultwarden_vzdump_preflight
|
|
changed_when: false
|
|
failed_when: false
|
|
|
|
- name: Require no active Proxmox backup before Vaultwarden PBS backup
|
|
ansible.builtin.assert:
|
|
that:
|
|
- vaultwarden_vzdump_preflight.rc != 0
|
|
fail_msg: >-
|
|
A Proxmox backup is already running on mini-pc.
|
|
Retry after the existing backup completes.
|
|
|
|
- name: Create a fresh Vaultwarden PBS backup
|
|
ansible.builtin.command:
|
|
argv:
|
|
- vzdump
|
|
- "{{ vaultwarden_vmid }}"
|
|
- --storage
|
|
- pbs
|
|
- --mode
|
|
- snapshot
|
|
- --exclude-path
|
|
- /var/lib/docker/fuse-overlayfs/*/merged
|
|
|
|
- name: Run current PBS backup audit on mini-pc
|
|
ansible.builtin.command:
|
|
argv:
|
|
- systemctl
|
|
- start
|
|
- --wait
|
|
- homelab-backup-audit-pbs.service
|
|
changed_when: true
|
|
|
|
- import_playbook: pve-vaultwarden.yml
|
|
vars:
|
|
pve_provisioning_enabled: false
|
|
|
|
- name: Verify Vaultwarden public endpoint after update
|
|
hosts: ru-vps
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Check Vaultwarden HTTPS endpoint
|
|
ansible.builtin.uri:
|
|
url: https://pass.ada-dev.ru/
|
|
status_code: 200
|
|
return_content: false
|
|
register: vaultwarden_public_health
|
|
retries: 24
|
|
delay: 5
|
|
until: vaultwarden_public_health.status == 200
|