feat: 按 doc_id 重组 ansible/files 与验证框架

- ansible/files 改为与文档 XX-YY 对齐的目录结构,更新相关 playbook 路径
- 新增 scripts/verify.sh 与 ansible/playbooks/verify/*.yml,移除单体 verify-matrix.yml
- 补充 docs/00-02 矩阵状态、00-05 验证框架与流程、00-04 环境与 ylc65 工作机说明
- 增加 k3s 存储准备、Longhorn、local-path 等 playbook 与辅助脚本

Made-with: Cursor
This commit is contained in:
2026-03-26 07:01:14 +08:00
parent a67788de56
commit 8c43761962
192 changed files with 4006 additions and 320 deletions

View File

@@ -0,0 +1,49 @@
- import_playbook: "{{ playbook_dir }}/../nodejs-demo-apply.yml"
- name: Verify 04-01 nodejs demo (rollout + HTTP)
hosts: k3s_server
become: true
run_once: true
vars:
k3s_kubeconfig: /etc/rancher/k3s/k3s.yaml
verify_entry_base: "{{ nodejs_entry_base | default('http://' ~ k3s_server_ip) }}"
tasks:
- name: Rollout status nodejs-demo
ansible.builtin.shell: |
set -e
KUBECONFIG={{ k3s_kubeconfig }} kubectl rollout status deployment/nodejs-demo -n default --timeout=180s
args:
executable: /bin/bash
changed_when: false
- name: HTTP check /node (expect 200 and Hello World)
ansible.builtin.shell: |
set -e
base="{{ verify_entry_base | trim | regex_replace('/+$','') }}"
url="$base/node"
code=$(curl -s -o /dev/null -w "%{http_code}" --connect-timeout 3 --max-time 8 "$url" 2>/dev/null || echo "000")
echo "$url -> $code"
test "$code" = "200"
body=$(curl -sS --connect-timeout 3 --max-time 8 "$url" 2>/dev/null || true)
echo "$body" | grep -q "Hello World from Node.js"
args:
executable: /bin/bash
changed_when: false
- name: Teardown 04-01 nodejs demo (optional)
hosts: k3s_server
become: true
run_once: true
vars:
k3s_kubeconfig: /etc/rancher/k3s/k3s.yaml
verify_teardown: "{{ (VERIFY_TEARDOWN | default('1')) | string }}"
tasks:
- name: Delete nodejs-demo resources when VERIFY_TEARDOWN=1
when: verify_teardown == "1"
ansible.builtin.shell: |
set -e
KUBECONFIG={{ k3s_kubeconfig }} kubectl delete deploy/nodejs-demo svc/nodejs-demo ing/nodejs-demo -n default --ignore-not-found=true
args:
executable: /bin/bash
changed_when: true