51 lines
1.4 KiB
YAML
51 lines
1.4 KiB
YAML
---
|
|
- name: Ensure host distribution is supported
|
|
ansible.builtin.import_role:
|
|
name: compatcheck
|
|
vars:
|
|
compatcheck_supported_distributions:
|
|
- name: debian
|
|
version_min: 11
|
|
- name: ubuntu
|
|
version_min: 20
|
|
|
|
- name: Add caddy apt repository
|
|
ansible.builtin.include_role:
|
|
name: apt_repository
|
|
vars:
|
|
repo_name: caddy-stable
|
|
repo_url: https://dl.cloudsmith.io/public/caddy/stable/deb/debian
|
|
repo_key_url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key
|
|
repo_suite: any-version
|
|
repo_components:
|
|
- main
|
|
when: >
|
|
(ansible_distribution == 'Debian' and ansible_distribution_major_version | int == 11) or
|
|
(ansible_distribution == 'Ubuntu' and ansible_distribution_major_version | int < 24)
|
|
|
|
- name: Install caddy
|
|
ansible.builtin.apt:
|
|
name: caddy
|
|
|
|
- name: Remove default settings from caddyfile
|
|
ansible.builtin.blockinfile:
|
|
path: /etc/caddy/Caddyfile
|
|
marker: "{mark}"
|
|
marker_begin: ':80 {'
|
|
marker_end: '# https://caddyserver.com/docs/caddyfile'
|
|
state: absent
|
|
validate: 'caddy validate --config %s --adapter caddyfile'
|
|
backup: true
|
|
|
|
- name: Put caddy general config in place
|
|
ansible.builtin.blockinfile:
|
|
path: /etc/caddy/Caddyfile
|
|
marker: "# {mark} ANSIBLE MANAGED BLOCK general"
|
|
block: |
|
|
{
|
|
email {{ caddy_admin_email }}
|
|
}
|
|
validate: 'caddy validate --config %s --adapter caddyfile'
|
|
backup: true
|
|
notify: Reload caddy
|