Skip to content

Commit

Permalink
Added caddy build with Cloudflare DNS module.
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht9277 committed Dec 2, 2024
1 parent fbcdaa2 commit f5e7347
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
36 changes: 34 additions & 2 deletions infra/ansible/playbooks/caddy.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- name: Run Go playbook
ansible.builtin.import_playbook: go.yaml
vars:
host: "{{ host }}"

- name: Caddy Setup
hosts: "{{ host }}"

Expand Down Expand Up @@ -41,15 +46,42 @@
vars:
ansible_ssh_user: "{{ admin_user }}"

- name: Install Caddy
- name: Download and install XCaddy GPG key
shell:
cmd: curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
creates: /usr/share/keyrings/caddy-xcaddy-archive-keyring.gpg
vars:
ansible_ssh_user: "{{ admin_user }}"

- name: Add XCaddy repository
shell:
cmd: curl -1sLf 'https://dl.cloudsmith.io/public/caddy/xcaddy/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-xcaddy.list
creates: /etc/apt/sources.list.d/caddy-xcaddy.list
vars:
ansible_ssh_user: "{{ admin_user }}"

- name: Install Caddy and XCaddy
become: true
apt:
update_cache: yes
name: caddy
name:
- caddy
- xcaddy
state: present
vars:
ansible_ssh_user: "{{ admin_user }}"

- name: Build Cloudflare DNS module for caddy
shell:
cmd: |
xcaddy build --with github.com/caddy-dns/cloudflare
sudo mv /home/{{ ansible_ssh_user }}/caddy /usr/bin/caddy
chdir: /home/{{ ansible_ssh_user }}/
vars:
ansible_ssh_user: "{{ admin_user }}"
environment:
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin"

- name: Enable caddy
become: true
systemd_service:
Expand Down
2 changes: 1 addition & 1 deletion infra/ansible/playbooks/telemetry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
- name: Add reverse proxy configuration to Caddyfile
become: true
blockinfile:
path: /etc/caddy/Caddyfile.test
path: /etc/caddy/Caddyfile
block: |
{{ caddy_metrics_url }} {
reverse_proxy localhost:{{ caddy_metrics_port }}
Expand Down

0 comments on commit f5e7347

Please sign in to comment.