- 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