mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-30 14:56:11 +00:00
fix(sys-svc-compose): wipe stale NFS volume state on dev/act swarm redeploy
Swarm reuses NFS-backed state across cluster rebuilds. A role then reads config persisted from a prior cluster while its database (a node-local volume) is fresh, causing install drift and stale-credential loops. Wipe each NFS-backed volume subdir before pre-create, gated to dev/act via RUNTIME so production state is never touched. Hoist the shared swarm and NFS guards to the include's when, and fold the per-item mapping check into the loop via selectattr, so the two tasks no longer repeat identical conditions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
1 parent
47729106e6
commit
fa48411ae5
2 files changed
+19
-11
No files matched your search
@@ -26,8 +26,17 @@
|
||||
include_tasks: "02_stack_host_prep.yml"
|
||||
when: IS_STACK_HOST | bool
|
||||
|
||||
- name: "Pre-create NFS subdirs declared by '{{ application_id }}' (swarm + NFS backend only)"
|
||||
include_tasks: "utils/nfs_prep.yml"
|
||||
- name: "Prepare NFS subdirs for '{{ application_id }}' (wipe stale in dev/act, then pre-create; swarm + NFS only)"
|
||||
include_tasks:
|
||||
file: "utils/nfs_prep.yml"
|
||||
apply:
|
||||
delegate_to: "{{ (groups['svc-storage-nfs-server'] | default([]))[0] | default(inventory_hostname) }}"
|
||||
run_once: true
|
||||
when:
|
||||
- DEPLOYMENT_MODE == 'swarm'
|
||||
- (storage.backend | default('local')) == 'nfs'
|
||||
- (groups['svc-storage-nfs-server'] | default([])) | length > 0
|
||||
- application_id not in lookup('roles_with_default_placement', 'manager')
|
||||
|
||||
- name: "Ensure that {{ lookup('container', application_id, 'directories.instance') }} is up"
|
||||
include_tasks: "utils/up.yml"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
---
|
||||
- name: "Wipe stale NFS data for '{{ application_id }}' volume '{{ item.key }}' before swarm (re)deploy (dev/act only)"
|
||||
ansible.builtin.file:
|
||||
path: "{{ STORAGE_NFS_STATE_PATH }}/{{ item.value.name | default(item.key) }}"
|
||||
state: absent
|
||||
loop: "{{ (lookup('compose_volumes', application_id) | from_yaml).volumes | default({}) | dict2items | selectattr('value', 'mapping') | list }}"
|
||||
when: RUNTIME in ['dev', 'act']
|
||||
|
||||
- name: "Pre-create NFS subdir for '{{ application_id }}' volume '{{ item.key }}' on the NFS server"
|
||||
ansible.builtin.file:
|
||||
path: "{{ STORAGE_NFS_STATE_PATH }}/{{ item.value.name | default(item.key) }}"
|
||||
@@ -6,12 +13,4 @@
|
||||
owner: "{{ (item.value.nfs | default({})).uid | default('0') | string }}"
|
||||
group: "{{ (item.value.nfs | default({})).gid | default('0') | string }}"
|
||||
mode: "{{ (item.value.nfs | default({})).mode | default('0755') }}"
|
||||
delegate_to: "{{ (groups['svc-storage-nfs-server'] | default([]))[0] | default(inventory_hostname) }}"
|
||||
run_once: true
|
||||
loop: "{{ (lookup('compose_volumes', application_id) | from_yaml).volumes | default({}) | dict2items }}"
|
||||
when:
|
||||
- DEPLOYMENT_MODE == 'swarm'
|
||||
- (storage.backend | default('local')) == 'nfs'
|
||||
- (groups['svc-storage-nfs-server'] | default([])) | length > 0
|
||||
- item.value is mapping
|
||||
- application_id not in lookup('roles_with_default_placement', 'manager')
|
||||
loop: "{{ (lookup('compose_volumes', application_id) | from_yaml).volumes | default({}) | dict2items | selectattr('value', 'mapping') | list }}"
|
||||
Reference in new issue
Block a user