An Ansible role to install nginx on Ubuntu based on h5bp's server configuration templates. It offers simple configuration of SSL hosts with the ability to use Let's Encrypt for the creation and renewal of free SSL certificates.
Hosts can be created with a simple dictionary as shown below.
Install via ansible-galaxy:
$ ansible-galaxy install dominik-bln.nginx-letsencrypt
Note: Currently nginx needs to be stopped shortly to create the new certificate. Hopfully this will be resolved when the nginx plugin of Let's encrypt is finished.
The most important configuration is the nginx_domains
dictionary where all host configuration is defined. Below shows an example with all possible options and their respective defaults when nothing is set. The only actually required value is admin_email
as long as letsencrypt
is set to true.
nginx_domains:
example.com:
# create a certificate with letsencrypt
letsencrypt: true
# email used for registering Let's Encrypt certificate
admin_email: [email protected]
# create a virtual host file in sites-enabled
create_vhost: true
# symlink to sites-enabled if the host file exists
enabled: true
# create a htdocs directory
create_htdocs: true
# create a simple index file in the htdocs
create_index: false
# redirect all http traffic to https
http_redirect: true
# additional aliases to redirect; separate with whitespace
redirects: www.example.com example.org
# specify the ssl_certifcate explicitly
ssl_certificate: false
# specify the ssl_certificate_key file
ssl_certificate_key: false
# specify the ssl_trusted_certificate file directly
trusted_cert: false
A lot of other paths and switches can be changed if necessary. Please consult defaults/main.yml
to see what is possible.
---
- hosts: webservers
roles:
- { role: dominik-bln.nginx-letsencrypt }
The role is only tested on Ubuntu 14.04 and with Ansible 1.9. There is a chance that it would work for other versions as well (testing would be very welcome).
- crontab for renewal of Let's encrypt certificates
- travis.ci tests
- custom nginx include file
- replaceable nginx template on a host basis
This project is licensed under an MIT license. It includes code from h5bp/server-config-nginx for the configuration of nginx.