damex.cloudflare.cloudflare_tunnel module – Ensure Cloudflare tunnel
Note
This module is part of the damex.cloudflare collection (version 1.2.3).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install damex.cloudflare.
To use it in a playbook, specify: damex.cloudflare.cloudflare_tunnel.
Synopsis
Ensures Cloudflare tunnels with ingress configuration.
See the docs: https://developers.cloudflare.com/cloudflare-one/networks/connectors/cloudflare-tunnel/.
Creates the tunnel if missing, updates ingress if changed, deletes if absent.
Returns the tunnel token for use with cloudflared.
Parameters
Parameter |
Comments |
|---|---|
Cloudflare account API key. Required together with |
|
Cloudflare account email. Required together with |
|
Cloudflare account identifier. Required if |
|
Cloudflare account name. Required if Resolved to account identifier via the Cloudflare API. |
|
Cloudflare API token. Required if Can be specified in |
|
Ingress rules for the tunnel. Must end with a catch-all rule without hostname. Required when |
|
Hostname to match. Omit for the catch-all rule. |
|
Origin request parameters. |
|
Service URL or status code. |
|
Tunnel name. |
|
Tunnel state. Choices:
|
Attributes
Attribute |
Support |
Description |
|---|---|---|
Support: full |
Supports check mode. |
|
Support: full |
Supports diff mode. |
Examples
- name: Ensure tunnel with ingress
damex.cloudflare.cloudflare_tunnel:
name: hetzner
account_name: damex
api_token: "{{ cloudflare_api_token }}"
ingress:
- hostname: forgejo.damex.org
service: http://localhost:3000
- hostname: nextcloud.damex.org
service: http://localhost:8080
- service: http_status:404
- name: Ensure tunnel is absent
damex.cloudflare.cloudflare_tunnel:
name: old-tunnel
account_name: damex
api_token: "{{ cloudflare_api_token }}"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
|---|---|
Tunnel object from the Cloudflare API. Returned: when state is present |
|
Tunnel identifier. Returned: success |
|
Tunnel name. Returned: success |
|
Tunnel status. Returned: success |