Add cloudflared tunnel config files and service

This commit is contained in:
Khue Doan 2021-05-03 21:52:59 +07:00
parent 27c048931f
commit 9e7f7909fd
3 changed files with 35 additions and 0 deletions

View File

@ -1,3 +1,25 @@
- name: Install cloudflared
apt:
deb: "{{ cloudflared_package_url }}"
- name: Create tunnel configuration file
template:
src: config.yml.j2
dest: /etc/cloudflared/config.yml
# TODO (feature) Get cloudflare tunnel credentials automatically
# - name: Create tunnel credentials file
# template:
# src: credentials.json.j2
# dest: /etc/cloudflared/credentials.json
- name: Install cloudfared system service
command: cloudflared service install
args:
creates: /etc/systemd/system/cloudflared.service
- name: Enable cloudflared service
service:
name: cloudflared
state: started
enabled: yes

View File

@ -0,0 +1,7 @@
tunnel: homelab-vpn
credentials-file: /etc/cloudflared/cert.pem
ingress:
- hostname: "*.khuedoan.com"
service: http://192.168.1.150 # TODO (optimize) Use variable for ingress address
- service: http_status:404

View File

@ -0,0 +1,6 @@
{
"TunnelName": "{{ tunnel_name }}",
"AccountTag": "{{ account_id }}",
"TunnelID": "{{ tunnel_id }}",
"TunnelSecret": "{{ tunnel_secret }}"
}