Files
2026-03-29 09:08:01 +08:00

23 lines
1.0 KiB
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 可复用:在 kube-system 下确保 cloudflared-credentials Secretkey=TUNNEL_TOKEN
# 调用方传入 verify_tunnel_token非空no_log勿在日志中回显 token。
- name: Assert verify_tunnel_token for cloudflared secret
ansible.builtin.assert:
that:
- verify_tunnel_token is defined
- (verify_tunnel_token | trim | length) > 0
fail_msg: "verify_common ensure-cloudflared-tunnel-secretverify_tunnel_token 为空"
- name: Apply cloudflared-credentials Secret in kube-system
ansible.builtin.shell: |
set -euo pipefail
KUBECONFIG={{ k3s_kubeconfig | default('/etc/rancher/k3s/k3s.yaml') }} kubectl -n kube-system create secret generic cloudflared-credentials \
--from-literal=TUNNEL_TOKEN="$TUNNEL_TOKEN" \
--dry-run=client -o yaml \
| KUBECONFIG={{ k3s_kubeconfig | default('/etc/rancher/k3s/k3s.yaml') }} kubectl apply -f -
environment:
TUNNEL_TOKEN: "{{ verify_tunnel_token | trim }}"
args:
executable: /bin/bash
changed_when: true
no_log: true