Installs cloudflared as a systemd service for a locally managed Cloudflare Tunnel: checks that the tunnel exists, manages its proxied CNAMEs, renders config.yml and the credentials file, and updates the binary through the internal _binary_update role. The opt-in mint entry point creates the tunnel and registers its id and credentials as no_log facts for the calling play to persist. Validation runs first under always and asserts the tunnel secrets with the mint instructions; the secrets stay optional in the argument spec on purpose. cloudflared_manage_dns lets the records be managed elsewhere. A removal now ends the role. Assisted-by: Claude Code:claude-opus-5-5
22 lines
698 B
YAML
22 lines
698 B
YAML
---
|
|
- name: Download and install cloudflared binary
|
|
ansible.builtin.include_tasks: download.yml
|
|
vars:
|
|
__cloudflared_download_dest: "{{ cloudflared_install_dir }}/cloudflared"
|
|
tags: [cloudflared, install]
|
|
|
|
- name: Ensure cloudflared binary exists
|
|
ansible.builtin.stat:
|
|
path: "{{ cloudflared_install_dir }}/cloudflared"
|
|
register: __cloudflared_binary
|
|
tags: [cloudflared, install, health]
|
|
|
|
- name: Fail if cloudflared binary missing
|
|
ansible.builtin.assert:
|
|
that:
|
|
- __cloudflared_binary.stat.exists
|
|
fail_msg: "cloudflared binary not found after download"
|
|
# Nothing is downloaded under --check.
|
|
when: not ansible_check_mode
|
|
tags: [cloudflared, install, health]
|