Automated LetsEncrypt SSL installation with Ansible

banner: ansible playbook for letsencrypt ssl setupNeed a simple SSL which will work in all browsers?

LetsEncrypt SSL is your choice! Even more you won’t even need to get into multi-step slow domain ownership validation which includes waiting for emails and waiting for Certificate Authority (CA) to react to your requests.

Why and when would one need a SSL certificate in the first place? Well, if you got a WordPress site (replace this with your favorite CMS/framework) which has any kind of authorization form, then you need an SSL, because you probably don’t want usernames and passwords flying over the Internet in plain text.

Besides we should also make a remark, that for applications like online shops or pretty much any apps working with various sorts of confidential information, you might need a non-free SSL. There is a number of reasons for that. The main reasons are the following:

– those certificates are displayed as more secure in clients browsers
– you get much better warranty payments for a (very unlikely) case of SSL hack

Ones who probably benefit the most from LetsEncrypt fast validation are system administrators of various levels.Β Above all Let’s Encrypt allows to use CLI certbots like officially recommended oneΒ at certbot.eff.orgΒ for obtaining and even installing certificates on some web servers. As a result it’s hard to overcome temptation to automate the process, making it easily repeatable for any number of sites you need.

Automated setup of LetsEncrypt SSL on your website

In this demonstration we will use Ansible as a configuration management tool. Likewise for automation purposes you can use many other similar tools like Chef, Puppet, maybe even Bash πŸ˜€ We prefer to use Ansible, as it’s very flexible in the borders of this task and doesn’t require many additional configurations compared to other alternatives.

Requirements to begin

DNS recordΒ pointing to IP of the server with the domains, which you will installed and configure SSL for
– Correct version of Ansible – it should be To check it you can execute the following command in your CLI:

OS: Ubuntu 16.04 installed on the target server
SSH key uploaded to the target server
Python-minimal installed on the target server
Nginx web-server, working from www-data folder
– Catalogue structure on the target server should be as follows:

Important files

– Conf.d – temporary configuration files for LetsEncrypt SSL are kept here
– Sites-available – configs of available websites
– Sites-enabled – connected websites

Also you should enable these strings in nginx.conf:


Hosts file:

ssl_domains – list of domains you want SSL to be installed and configured for
le_email – e-mail address for LetsEncrypt SSL notifications

Playbook launch

You can download role here:Β

Note that any SSL won’t fully protect your website from various attacks and possible hacks. There’re other numerous security approaches and standards that you should review in order to be sure, that your website and server are protected. We’re talking about this topic in one of our articles.

ITsyndicate contact form

Contact us if you have any questions!