- 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
67 lines
2.0 KiB
YAML
67 lines
2.0 KiB
YAML
- name: Deploy 03-05 local-path PVC demo
|
|
hosts: k3s_server
|
|
become: true
|
|
run_once: true
|
|
vars:
|
|
k3s_kubeconfig: /etc/rancher/k3s/k3s.yaml
|
|
manifest_src: "{{ playbook_dir }}/../../files/03-05-local-path-demo/local-path-pvc-demo.yaml"
|
|
manifest_dest: /tmp/local-path-pvc-demo.yaml
|
|
tasks:
|
|
- name: Copy manifest to server
|
|
ansible.builtin.copy:
|
|
src: "{{ manifest_src }}"
|
|
dest: "{{ manifest_dest }}"
|
|
mode: "0644"
|
|
|
|
- name: kubectl apply
|
|
ansible.builtin.shell: |
|
|
set -e
|
|
KUBECONFIG={{ k3s_kubeconfig }} kubectl apply -f {{ manifest_dest }}
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: true
|
|
|
|
- name: Verify 03-05 local-path PVC demo
|
|
hosts: k3s_server
|
|
become: true
|
|
run_once: true
|
|
vars:
|
|
k3s_kubeconfig: /etc/rancher/k3s/k3s.yaml
|
|
tasks:
|
|
- name: Wait nginx-local-pvc-demo deployment ready
|
|
ansible.builtin.shell: |
|
|
set -e
|
|
KUBECONFIG={{ k3s_kubeconfig }} kubectl rollout status deployment/nginx-local-pvc-demo -n default --timeout=180s
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
|
|
- name: Assert PVC is Bound
|
|
ansible.builtin.shell: |
|
|
set -e
|
|
phase=$(KUBECONFIG={{ k3s_kubeconfig }} kubectl get pvc local-pvc-demo -n default -o jsonpath='{.status.phase}')
|
|
echo "pvc phase=$phase"
|
|
test "$phase" = "Bound"
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: false
|
|
|
|
- name: Teardown 03-05 local-path PVC 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 }}"
|
|
manifest_dest: /tmp/local-path-pvc-demo.yaml
|
|
tasks:
|
|
- name: Delete resources when VERIFY_TEARDOWN=1
|
|
when: verify_teardown == "1"
|
|
ansible.builtin.shell: |
|
|
set -e
|
|
KUBECONFIG={{ k3s_kubeconfig }} kubectl delete -f {{ manifest_dest }} --ignore-not-found=true
|
|
args:
|
|
executable: /bin/bash
|
|
changed_when: true
|
|
|