Ansible playbook for caddy
Switch branches/tags
Clone or download
Pull request Compare This branch is 45 commits behind antoiner77:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
defaults
handlers
meta
tasks
templates
tests
vars
.gitignore
.travis.yml
README.md
Vagrantfile
ansible.cfg

README.md

Build Status Galaxy Role

Caddy Ansible Role

This role installs and configures the caddy web server. The user can specify any http configuration parameters they wish to apply their site. Any number of sites can be added with configurations of your choice.

Dependencies

None

Role Variables

The Caddyfile (notice the pipe)
default:

caddy_config: |
  localhost:2020
  gzip
  # tls email@example.com
  root /var/www
  git github.com/antoiner77/caddy-ansible

Auto update Caddy?
default:

caddy_update: yes

Features that can be added to core: DNS, awslambda, cors, expires, filemanager, filter, git, hugo, ipfilter, jsonp, jwt, locale, mailout, minify, multipass, prometheus, ratelimit, realip, search, upload
Changing this variable will reinstall Caddy with the new features if caddy_update is enabled
default:

caddy_features: git

Use setcap for allowing Caddy to open a low port (e.g. 80, 443)?
default:

caddy_setcap: yes

Verify the PGP signature on download?

caddy_pgp_verify_signatures: no

Use systemd capabilities controls
default:

caddy_systemd_capabilities_enabled: False
caddy_systemd_capabilities: "CAP_NET_BIND_SERVICE"

NOTE: This feature requires systemd v229 or newer and might be needed in addition to caddy_setcap: yes.

Supported:

  • Debian 9 (stretch)
  • Fedora 25
  • Ubuntu 16.04 (xenial)

RHEL/CentOS has no release that supports systemd capability controls at this time.

Example Playbook

---
- hosts: all
  roles:
    - role: caddy-ansible
      caddy_config: |
        localhost:2020
        gzip

        tls email@example.com

        root /var/www
        git github.com/antoiner77/caddy-ansible

Debugging

If the service fails to start you can figure out why by looking at the output of Caddy.
Upstart (ubuntu, debian wheezy, centos/rhel 6)
tail /var/log/upstart/caddy.log
Systemd (debian jessie, centos/rhel 7)
systemctl status caddy -l

If something doesn't seem right, open an issue!

Contributing

Pull requests are welcome. Please test your changes beforehand with vagrant:

vagrant up
vagrant provision (since it already provisioned there should be no changes here)
vagrant destroy