65 lines
1.5 KiB
YAML
65 lines
1.5 KiB
YAML
---
|
|
- name: Install Caddy prerequisites
|
|
apt:
|
|
name:
|
|
- debian-keyring
|
|
- debian-archive-keyring
|
|
- apt-transport-https
|
|
state: present
|
|
|
|
- name: Add Caddy GPG key
|
|
shell: curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
|
args:
|
|
creates: /usr/share/keyrings/caddy-stable-archive-keyring.gpg
|
|
|
|
- name: Add Caddy repo
|
|
shell: curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list
|
|
args:
|
|
creates: /etc/apt/sources.list.d/caddy-stable.list
|
|
|
|
- name: Install Caddy
|
|
apt:
|
|
name: caddy
|
|
state: present
|
|
update_cache: yes
|
|
|
|
- name: Create Caddy certs directory
|
|
file:
|
|
path: /etc/caddy/certs
|
|
state: directory
|
|
owner: caddy
|
|
group: caddy
|
|
mode: "0700"
|
|
|
|
- name: Deploy Cloudflare origin certificate
|
|
copy:
|
|
content: "{{ vault_ssl_certificate }}"
|
|
dest: /etc/caddy/certs/origin.pem
|
|
owner: caddy
|
|
group: caddy
|
|
mode: "0600"
|
|
notify: Reload Caddy
|
|
|
|
- name: Deploy Cloudflare origin key
|
|
copy:
|
|
content: "{{ vault_ssl_private_key }}"
|
|
dest: /etc/caddy/certs/origin-key.pem
|
|
owner: caddy
|
|
group: caddy
|
|
mode: "0600"
|
|
notify: Reload Caddy
|
|
|
|
- name: Deploy Caddyfile
|
|
template:
|
|
src: Caddyfile.j2
|
|
dest: /etc/caddy/Caddyfile
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
notify: Reload Caddy
|
|
|
|
- name: Enable and start Caddy
|
|
service:
|
|
name: caddy
|
|
state: started
|
|
enabled: yes
|