I have spent some time trying to convert the curl | bash magic coming from official Caddy docs to an ansible playbook. At the time of writing, the official installation for Caddy on Ubuntu 22.04 current LTS looks like this: sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy

Which outputs the following: # Source: Caddy # Site: https://github.com/caddyserver/caddy # Repository: Caddy / stable # Description: Fast, multi-platform web server with automatic HTTPS deb [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main deb-src [signed-by=/usr/share/keyrings/caddy-stable-archive-keyring.gpg] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main

With the freshly gathered knowledge, we can construct the following two tasks: - name: Add Caddy repository to sources list apt_repository: repo: "deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" state: present filename: caddy-stable - name: Add Caddy src repository to sources list apt_repository: repo: "deb-src https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" state: present filename: caddy-stable

The final playlist thus looks like this: --- - name: Install Caddy web server hosts: my_hosts become: true become_user: root tasks: - name: Install required packages apt: update_cache: yes name: - debian-keyring - debian-archive-keyring - apt-transport-https state: present - name: Add Cloudsmith repository apt_key: url: "https://dl.cloudsmith.io/public/caddy/stable/gpg.key" state: present - name: Add Caddy repository to sources list apt_repository: repo: "deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" state: present filename: caddy-stable - name: Add Caddy src repository to sources list apt_repository: repo: "deb-src https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main" state: present filename: caddy-stable - name: Install Caddy apt: update_cache: yes name: caddy state: present - name: Enable and start Caddy service service: name: caddy enabled: yes state: started
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners