Skip to content

Commit c4aaf7e

Browse files
committed
fix: batcher ansible
1 parent 24b6c94 commit c4aaf7e

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed

infra/ansible/playbooks/caddy.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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 }}"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[global]
2+
batcher_domain=
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# The Caddyfile is an easy way to configure your Caddy web server.
2+
3+
# To use your own domain name (with automatic HTTPS), first make
4+
# sure your domain's A/AAAA DNS records are properly pointed to
5+
# this machine's public IP, then replace ":80" below with your
6+
# domain name.
7+
8+
# Refer to the Caddy docs for more information:
9+
# https://caddyserver.com/docs/caddyfile
10+
11+
{{ batcher_domain }} {
12+
reverse_proxy localhost:8080
13+
}

0 commit comments

Comments
 (0)