Install and configures the caddy webserver.
GitHub | Downloads | Version |
---|---|---|
This example is taken from molecule/default/converge.yml
and is tested on each push, pull request and release.
---
- name: Converge
hosts: all
become: true
gather_facts: true
vars:
caddy_config_snippets:
- name: tls
config: |
tls /etc/ssl/cert.pem /etc/ssl/key.pem
caddy_config_sites:
- name: :80
config: |
root * /usr/share/caddy
file_server
roles:
- role: "mullholland.caddy"
The machine needs to be prepared. In CI this is done using molecule/default/prepare.yml
:
---
- name: Prepare
hosts: all
become: true
gather_facts: true
roles:
- role: mullholland.repository_caddy
The default values for the variables are set in defaults/main.yml
:
---
# systemd
caddy_service_after_units: []
caddy_service_require_units: []
caddy_env_vars: []
# Vhosts
caddy_config_globals: |
# Enable Prometheus metrics
servers {
metrics
}
caddy_config_snippets: []
# - name: tls
# config: |
# tls /etc/ssl/cert.pem /etc/ssl/key.pem
# https://caddyserver.com/docs/caddyfile/patterns
caddy_config_sites: []
# # Static file server
# - name: example.com
# config: |
# root * /var/www
# file_server
# # Reverse proxy
# # Proxy all requests
# - name: example.com
# config: |
# reverse_proxy localhost:5000
# # Only proxy requests having a path starting with /api/
# # and serve static files for everything else
# - name: example.com
# config: |
# root * /var/www
# reverse_proxy /api/* localhost:5000
# file_server
# # php
# - name: example.com
# config: |
# root * /srv/public
# encode gzip
# php_fastcgi localhost:9000
# file_server
# # php
# - name: example.com
# config: |
# root * /srv/public
# encode gzip
# php_fastcgi localhost:9000
# file_server
# # redirect
# # To add the www. subdomain with an HTTP redirect
# - name: example.com
# config: |
# redir https://www.{host}{uri}
# # To remove it
# - name: example.com
# config: |
# redir https://example.com{uri}
# # tls
# # Wildcard certificates
# - name: "*.example.com"
# config:
# tls {
# dns <provider_name> [<params...>]
# }
#
# @foo host foo.example.com
# handle @foo {
# respond "Foo!"
# }
#
# @bar host bar.example.com
# handle @bar {
# respond "Bar!"
# }
#
# # Fallback for otherwise unhandled domains
# handle {
# abort
# }
- pip packages listed in requirements.txt.
The following roles are used to prepare a system. You can prepare your system in another way.
Requirement | GitHub | GitLab |
---|---|---|
mullholland.repository_caddy |
This role is a part of many compatible roles. Have a look at the documentation of these roles for further information.
Here is an overview of related roles:
This role has been tested on these container images:
container | tags |
---|---|
EL | all |
Ubuntu | all |
Debian | all |
The minimum version of Ansible required is 2.10, tests have been done to:
- The previous version.
- The current version.
- The development version.
If you find issues, please register them in GitHub.
MIT.