Created
December 9, 2024 11:41
-
-
Save atticus-sullivan/ce6352fc9b755ec82f3217ffcc7ef8ce to your computer and use it in GitHub Desktop.
caddy/tasks/main.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| - name: Add Caddy GPG key | |
| ansible.builtin.get_url: | |
| url: https://dl.cloudsmith.io/public/caddy/stable/gpg.key | |
| dest: /usr/share/keyrings/caddy-stable-archive-keyring.asc | |
| owner: root | |
| group: root | |
| mode: 'u=rw,go=r' | |
| register: add_key | |
| - name: Prerequisite Packages | |
| ansible.builtin.apt: | |
| name: libnss3-tools | |
| state: present | |
| - name: Add Caddy APT repository | |
| ansible.builtin.copy: | |
| dest: /etc/apt/sources.list.d/caddy-stable.list | |
| content: | | |
| # Source: Caddy | |
| # Site: https://github.com/caddyserver/caddy | |
| # Repository: Caddy / stable | |
| # Description: Fast, multi-platform web server with automatic HTTPS | |
| deb [signed-by={{ add_key.dest }}] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main | |
| deb-src [signed-by={{ add_key.dest }}] https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main | |
| owner: root | |
| group: root | |
| mode: '0644' | |
| - name: Install Caddy | |
| ansible.builtin.apt: | |
| update_cache: true | |
| name: caddy | |
| state: present | |
| - name: Ensure Caddy configuration directory exists | |
| ansible.builtin.file: | |
| path: "{{ caddy_config_path }}" | |
| state: directory | |
| owner: root | |
| group: root | |
| mode: 'u=rwx,go=rx' | |
| - name: Upload Caddyfile | |
| ansible.builtin.template: | |
| src: "Caddyfile.j2" | |
| dest: "{{ caddy_config_path }}/Caddyfile" | |
| owner: root | |
| group: root | |
| mode: 'u=rw,go=r' | |
| validate: "caddy validate --config %s" | |
| notify: "Caddy : Reload" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment