--- - name: Deploy Cluster Applications hosts: master # Run this ONLY on the master (or localhost) become: no vars: project_root: "/mnt/f/Invixel/k8s-infra-cluster" namespaces: ["infra", "stream", "apps"] win_user: "wendg2" tasks: - name: Ensure WSL .kube directory exists delegate_to: localhost become: no ansible.builtin.file: path: "~/.kube" state: directory mode: '0700' - name: Link Windows Kubeconfig to WSL (Fixes Helm/Kubectl) delegate_to: localhost become: no ansible.builtin.file: src: "/mnt/c/Users/{{ win_user }}/.kube/config" dest: "~/.kube/config" state: link # - name: Deploy Infra via Kustomize # ansible.builtin.shell: "kustomize build --enable-helm . | kubectl apply --server-side --force-conflicts --insecure-skip-tls-verify -f -" # args: # chdir: "{{ project_root }}" # delegate_to: localhost # <--- CRITICAL: Run on your laptop # become: no # Your laptop doesn't need sudo for this - name: Install Cosmo Router via Helm # Use upgrade --install to prevent "already exists" errors ansible.builtin.shell: "helm upgrade --install cosmo-router ./cosmo-router -n apps" args: chdir: "{{ project_root }}" delegate_to: localhost # <--- CRITICAL: Run on your laptop become: no # Your laptop doesn't need sudo for this - name: Apply Linkerd CRDs ansible.builtin.shell: "kustomize build --enable-helm . | kubectl apply --server-side --force-conflicts --insecure-skip-tls-verify -f -" args: chdir: "{{ project_root }}/linkerd" delegate_to: localhost # <--- ADD THIS, Ansible use the Python environment on our laptop become: no # Laptop doesn't need sudo - name: Annotate Namespaces for Linkerd Injection ansible.builtin.shell: | kubectl annotate namespace {{ item }} linkerd.io/inject=enabled --overwrite --insecure-skip-tls-verify loop: "{{ namespaces }}" delegate_to: localhost # <--- ADD THIS, Ansible use the Python environment on our laptop become: no # Laptop doesn't need sudo register: annot_result until: annot_result.rc == 0 retries: 5 # Try 5 times delay: 10 # Wait 10 seconds between tries # export ANSIBLE_CONFIG=./ansible.cfg # ansible-playbook -i hosts.ini deploy-k3s.yml # ansible k8s_nodes -i hosts.ini -m ping