tenseleyflow/shithub / 07941aa

Browse files

S37: Ansible caddy role

Authored by espadonne
SHA
07941aa4a1c60d60198144753c45cf1dc31cf8fa
Parents
ca1982c
Tree
e6646e5

2 changed files

StatusFile+-
A deploy/ansible/roles/caddy/handlers/main.yml 3 0
A deploy/ansible/roles/caddy/tasks/main.yml 24 0
deploy/ansible/roles/caddy/handlers/main.ymladded
@@ -0,0 +1,3 @@
1
+---
2
+- name: reload caddy
3
+  systemd: { name: caddy, state: reloaded }
deploy/ansible/roles/caddy/tasks/main.ymladded
@@ -0,0 +1,24 @@
1
+---
2
+# SPDX-License-Identifier: AGPL-3.0-or-later
3
+- name: Caddy — install (apt repo)
4
+  shell: |
5
+    if ! command -v caddy >/dev/null; then
6
+      apt -y install debian-keyring debian-archive-keyring apt-transport-https
7
+      curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' \
8
+        | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
9
+      curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' \
10
+        | tee /etc/apt/sources.list.d/caddy-stable.list
11
+      apt update && apt -y install caddy
12
+    fi
13
+  args:
14
+    creates: /usr/bin/caddy
15
+
16
+- name: Caddyfile — render
17
+  template:
18
+    src: "{{ playbook_dir }}/../Caddyfile.j2"
19
+    dest: /etc/caddy/Caddyfile
20
+    mode: "0644"
21
+  notify: reload caddy
22
+
23
+- name: Caddy — enabled + started
24
+  systemd: { name: caddy, state: started, enabled: yes }