Files
Defame1297 e308683431 feat(cloudflared): add the cloudflared role
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
2026-11-23 14:22:16 +00:00

40 lines
1.1 KiB
YAML

---
- name: Create cloudflared group
become: true
ansible.builtin.group:
name: "{{ cloudflared_group }}"
system: true
tags: [cloudflared, prereqs, always]
- name: Create cloudflared user
become: true
ansible.builtin.user:
name: "{{ cloudflared_user }}"
group: "{{ cloudflared_group }}"
shell: /usr/sbin/nologin
comment: "Cloudflare Tunnel daemon"
system: true
create_home: false
tags: [cloudflared, prereqs, always]
- name: Create cloudflared config directory
become: true
ansible.builtin.file:
path: "{{ cloudflared_config_dir }}"
state: directory
owner: "{{ cloudflared_user }}"
group: "{{ cloudflared_group }}"
mode: "0750"
tags: [cloudflared, prereqs, always]
- name: Check if cloudflared binary exists
ansible.builtin.stat:
path: "{{ cloudflared_install_dir }}/cloudflared"
register: __cloudflared_binary
tags: [cloudflared, prereqs, always]
- name: Set cloudflared facts
ansible.builtin.set_fact:
__cloudflared_installed: "{{ __cloudflared_binary.stat.exists }}"
tags: [cloudflared, prereqs, always]