68 lines
2.3 KiB
YAML
68 lines
2.3 KiB
YAML
- name: Ensure Caddy repo prerequisites
|
|
ansible.builtin.apt:
|
|
name:
|
|
- ca-certificates
|
|
- gnupg
|
|
state: present
|
|
update_cache: true
|
|
when:
|
|
- "(ansible_facts['distribution'] == 'Debian' and (ansible_facts['distribution_version'] is version('13', '=='))) or (ansible_facts['distribution'] == 'Ubuntu' and (ansible_facts['distribution_version'] is version('24.04', '==')))"
|
|
|
|
- name: Ensure apt keyring directory exists
|
|
ansible.builtin.file:
|
|
path: /etc/apt/keyrings
|
|
state: directory
|
|
owner: root
|
|
group: root
|
|
mode: '0755'
|
|
|
|
- name: Download Caddy GPG key
|
|
ansible.builtin.get_url:
|
|
url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key
|
|
dest: /etc/apt/keyrings/caddy-stable.asc
|
|
mode: '0644'
|
|
|
|
- name: Dearmor Caddy GPG key
|
|
ansible.builtin.command:
|
|
cmd: gpg --dearmor -o /etc/apt/keyrings/caddy-stable.gpg /etc/apt/keyrings/caddy-stable.asc
|
|
creates: /etc/apt/keyrings/caddy-stable.gpg
|
|
|
|
- name: Add Caddy repository (Debian)
|
|
ansible.builtin.apt_repository:
|
|
repo: "deb [signed-by=/etc/apt/keyrings/caddy-stable.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main"
|
|
filename: caddy-stable
|
|
state: present
|
|
when:
|
|
- ansible_facts['distribution'] == 'Debian'
|
|
- ansible_facts['distribution_version'] is version('13', '==')
|
|
|
|
- name: Add Caddy repository (Ubuntu)
|
|
ansible.builtin.apt_repository:
|
|
repo: "deb [signed-by=/etc/apt/keyrings/caddy-stable.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/ubuntu any-version main"
|
|
filename: caddy-stable
|
|
state: present
|
|
when:
|
|
- ansible_facts['distribution'] == 'Ubuntu'
|
|
- ansible_facts['distribution_version'] is version('24.04', '==')
|
|
|
|
- name: Install Caddy
|
|
ansible.builtin.apt:
|
|
name: caddy
|
|
state: present
|
|
update_cache: true
|
|
when:
|
|
- "(ansible_facts['distribution'] == 'Debian' and (ansible_facts['distribution_version'] is version('13', '=='))) or (ansible_facts['distribution'] == 'Ubuntu' and (ansible_facts['distribution_version'] is version('24.04', '==')))"
|
|
|
|
- name: Deploy Caddyfile
|
|
ansible.builtin.template:
|
|
src: Caddyfile.j2
|
|
dest: /etc/caddy/Caddyfile
|
|
mode: '0644'
|
|
notify: Reload caddy
|
|
|
|
- name: Ensure Caddy is running
|
|
ansible.builtin.service:
|
|
name: caddy
|
|
state: started
|
|
enabled: true
|