Find file
Fetching contributors…
Cannot retrieve contributors at this time
191 lines (123 sloc) 5.76 KB

System configuration

File system layout

The role will setup a configurable directory layout to store the certificates and make them accessible by the services.

Example layout of the default configuration:

Server path Ansible role variable
:file:`/etc/ssl/acme-tiny` :envvar:`acme_tiny__config_dir`
:file:`/etc/ssl/acme-tiny/` :envvar:`acme_tiny__cert_dir`
:file:`/etc/ssl/acme-tiny/` :envvar:`acme_tiny__private_key`
:file:`/etc/ssl/acme-tiny/` :envvar:`acme_tiny__cert_request`
:file:`/etc/ssl/acme-tiny/` :envvar:`acme_tiny__certificate`

When :envvar:`acme_tiny__service` is not empty and an additional layer of indirection through symlinks which will make the certificates accessible in a transparent way. For each service the role will create a :file:`ssl/` subdirectory from where the actual certificates and keys are symlinked. Like this the CA could be changed easily without reconfiguration of the secured services. This behavour can be disabled by setting :envvar:`acme_tiny__cert_symlink` to False.

E.g. For for Apache :program:`httpd` this would look like this:

/etc/apache2/ssl/ -> /etc/ssl/acme-tiny/
/etc/apache2/ssl/ -> /etc/ssl/acme-tiny/

For :program:`lighttpd`:

/etc/lighttpd/ssl/ -> /etc/ssl/acme-tiny/
/etc/lighttpd/ssl/ca.crt          -> /etc/ssl/acme-tiny/intermediate.crt

Service configuration

To secure a service the key and certificate have to be referenced in the individual service configurations. When using the symlinks created by the role this only has to be done once. Any certificate changes and even the change of a certificate authority can be easily handled by pointing the symlinks to a new target.


The configuration of the certificates in the service configuration files has to be done manually.

Apache httpd

SSLCertificateFile    /etc/apache2/ssl/
SSLCertificateKeyFile /etc/apache2/ssl/


ssl_cert = </etc/dovecot/ssl/
ssl_key  = </etc/dovecot/ssl/


ssl.pemfile /etc/lighttpd/ssl/
ssl.cafile  /etc/lighttpd/ssl/ca.crt


ssl_certificate     /etc/nginx/ssl/
ssl_certificate_key /etc/nginx/ssl/


smtpd_tls_cert_file = /etc/nginx/ssl/
smtpd_tls_key_file  = /etc/nginx/ssl/

Custom services

The :envvar:`acme_tiny__service_map` configuration dictionary can be overwritten from the Ansible inventory to extend the definition with a new service or adjust the current behaviour. Each element has the service name as key and needs to define the following properties:

Certificate format. See :envvar:`acme_tiny__cert_format` for valid options.
Custom directory from where the certificate and key will be symlinked. See :ref:`acme_tiny_ref_fs_layout` for more details.
Command which should be executed to restart this service (instance) as an unprivileged user. If this command contains :program:`sudo`, a corresponding rule will be created for the :envvar:`acme_tiny__user_name` account.


Custom Ansible inventory definition for Pound:

    cert_format: 'keycert'
    cert_directory: '/etc/pound/ssl'
    restart_command: '/usr/bin/sudo -n /usr/bin/systemctl restart pound'

Certificate renewal

After adding a new domain the role has to be run once with root privileges. Among other things this will create a separate user account acmetiny which can be used to schedule unattended certificate renewals.


See :ref:`acme_tiny_ref_example_inventory` for an example how to create a role configuration.

Here an example of a :program:`cron` job (:file:`/etc/cron.d/acme-tiny`) which whould renew the certificate every month:


@monthly acmetiny /usr/bin/ansible-playbook -e @/etc/ansible/vars/ /etc/ansible/playbooks/acme_tiny.yml >/dev/null