1+ - name : Caddy Setup
2+ hosts : " {{ host }}"
3+
4+ tasks :
5+ - name : Allow http/https traffic on UFW
6+ become : true
7+ ufw :
8+ rule : allow
9+ state : enabled
10+ port : ' {{ item }}'
11+ loop :
12+ - http
13+ - https
14+ vars :
15+ ansible_ssh_user : " {{ admin_user }}"
16+
17+ - name : Install dependencies for Caddy
18+ become : true
19+ apt :
20+ name :
21+ - debian-keyring
22+ - debian-archive-keyring
23+ - apt-transport-https
24+ - curl
25+ state : present
26+ update_cache : yes
27+ vars :
28+ ansible_ssh_user : " {{ admin_user }}"
29+
30+ - name : Download and install Caddy GPG key
31+ shell :
32+ cmd : curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
33+ creates : /usr/share/keyrings/caddy-stable-archive-keyring.gpg
34+ vars :
35+ ansible_ssh_user : " {{ admin_user }}"
36+
37+ - name : Add Caddy repository
38+ shell :
39+ cmd : curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
40+ creates : /etc/apt/sources.list.d/caddy-stable.list
41+ vars :
42+ ansible_ssh_user : " {{ admin_user }}"
43+
44+ - name : Download and install XCaddy GPG key
45+ shell :
46+ cmd : curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
47+ creates : /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
48+ vars :
49+ ansible_ssh_user : " {{ admin_user }}"
50+
51+ - name : Add XCaddy repository
52+ shell :
53+ cmd : curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
54+ creates : /etc/apt/sources.list.d/caddy-xcaddy.list
55+ vars :
56+ ansible_ssh_user : " {{ admin_user }}"
57+
58+ - name : Install Caddy and XCaddy
59+ become : true
60+ apt :
61+ update_cache : yes
62+ name :
63+ - caddy
64+ - xcaddy
65+ state : present
66+ vars :
67+ ansible_ssh_user : " {{ admin_user }}"
68+
69+ - name : Build Cloudflare DNS module for caddy
70+ shell :
71+ cmd : |
72+ xcaddy build --with github.com/caddy-dns/cloudflare
73+ sudo mv /home/{{ ansible_ssh_user }}/caddy /usr/bin/caddy
74+ chdir : /home/{{ ansible_ssh_user }}/
75+ vars :
76+ ansible_ssh_user : " {{ admin_user }}"
77+ environment :
78+ PATH : " {{ ansible_env.PATH }}:/usr/local/go/bin"
79+
80+ - name : Enable caddy
81+ become : true
82+ systemd_service :
83+ name : caddy
84+ enabled : true
85+ state : started
86+ vars :
87+ ansible_ssh_user : " {{ admin_user }}"
0 commit comments