forked from ayystudentunion/ayy-subdomain-redirect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
redirect-playbook.yaml
58 lines (50 loc) · 1.51 KB
/
redirect-playbook.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
- name: Playbook Name
hosts: all
become: true
tasks:
- name: Install Caddy's dependencies
ansible.builtin.apt:
name:
- debian-keyring
- debian-archive-keyring
- apt-transport-https
state: present
- name: Add Caddy's repositorys GPG key
ansible.builtin.apt_key:
url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key
keyring: /usr/share/keyrings/caddy-stable-archive-keyring.gpg
state: present
- name: Add Caddy's repository
ansible.builtin.apt_repository:
filename: caddy-stable
repo: deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main
state: present
- name: Install Caddy
ansible.builtin.apt:
name: caddy
state: present
- name: Ensure that Caddy is running and enabled
ansible.builtin.service:
name: caddy
state: started
enabled: true
- name: Add subdomain variables
ansible.builtin.include_vars:
dir: ./subdomains
name: subdomains
extensions: ["yaml", "yml"]
- name: Create Caddyfile from template
ansible.builtin.template:
src: ./templates/Caddyfile.j2
dest: /etc/caddy/Caddyfile
owner: root
group: root
mode: 0644
notify:
- Reload Caddy
handlers:
- name: Reload Caddy
ansible.builtin.service:
name: caddy
state: reloaded