Skip to content

Commit 98a39b7

Browse files
committed
Added caddy build with Cloudflare DNS module.
1 parent beca81b commit 98a39b7

1 file changed

Lines changed: 92 additions & 0 deletions

File tree

infra/ansible/playbooks/caddy.yaml

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

0 commit comments

Comments
 (0)