Infrastructure/ansible/roles/reverse-proxy/tasks/main.yml

47 lines
927 B
YAML
Raw Permalink Normal View History

2024-02-17 11:00:06 +02:00
---
- name: Install Caddy
ansible.builtin.package:
name: caddy
state: present
- name: Update Caddyfile
ansible.builtin.copy:
src: Caddyfile
dest: /etc/caddy/Caddyfile
2024-02-19 10:56:04 +02:00
mode: "644"
2024-02-17 11:00:06 +02:00
- name: Create site config directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
2024-02-19 10:56:04 +02:00
mode: "755"
2024-02-17 11:00:06 +02:00
with_items:
- /etc/caddy/sites-available
- /etc/caddy/sites-enabled
2024-02-18 09:52:10 +02:00
- /var/log/caddy
- name: Configure logging dir
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: caddy
group: caddy
2024-02-19 10:56:04 +02:00
mode: "755"
2024-02-18 09:52:10 +02:00
with_items:
- /var/log/caddy
2024-02-17 11:00:06 +02:00
- name: Enable and start the Caddy server
ansible.builtin.service:
name: caddy.service
enabled: true
state: started
2024-02-18 09:52:10 +02:00
- name: Configure nftables
ansible.builtin.copy:
dest: /etc/nftables/input.d/caddy.nft
src: caddy.nft
2024-02-19 10:56:04 +02:00
mode: "644"
2024-02-18 09:52:10 +02:00
when: firewall is defined
notify: Restart nftables