Need help with ansible-letsencrypt?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

440 Stars 123 Forks GNU General Public License v3.0 124 Commits 14 Opened issues


An ansible role to generate TLS certificates and get them signed by Let's Encrypt

Services available


Need anything else?

Contributors list


An ansible role to generate TLS certificates and get them signed by Let's Encrypt.

Currently attempts first to use the

authenticator, then if that fails to create certificates, it will use the standalone authenticator. This is handy for generating certs on a fresh machine before the web server has been configured or even installed.

Supported platforms

  • Debian Jessie
  • Debian Stretch
  • Debian Buster
  • Ubuntu Xenial

On other platforms this role will try to install letsencrypt using pip, which is not officially supported and may break over upgrades at least.

If you test it on other platforms please let me know the results (positive or otherwise) so I can document them here and/or fix the issue.

Requires Ansible >= 2.0


First, read Let's Encrypt's TOS and EULA. Only proceed if you agree to them.

The following variables are available:

is the root path that gets served by your web server. Defaults to

needs to be set to your email address. Let's Encrypt wants it. Defaults to
[email protected]{{ ansible_fqdn }}
. If you really want to register without providing an email address, define the variabe

allows to specify a size for the generated key.

is a list of domains you wish to get a certificate for. It defaults to a single item with the value of
{{ ansible_fqdn }}

should probably be left alone, but if you set it, it will change where the letsencrypt program is installed.

add arguments to the
letsencrypt renewal
command that gets run using cron. For example, use the renewal hooks to restart a web server.

adds arguments to the standalone authentication method. This is mostly useful for specifying supported challenges, such as
--standalone-supported-challenges tls-sni-01
to limit the authentication to port 443 if something is already running on 80 or vice versa.

sets the alternative auth server if needed. For example, during tests it's set to
to use the staging server (far higher rate limits, but certs are not trusted). It is not set by default.

symlinks the certificates to provided path if both are set.

The Let's Encrypt client will put the certificate and accessories in

. For more info, see the Let's Encrypt documentation.

Example Playbook

 - hosts: tls_servers
   user: root
     - role: letsencrypt
       letsencrypt_webroot_path: /var/www/html
       letsencrypt_email: [email protected]
       letsencrypt_renewal_command_args: '--renew-hook "systemctl restart nginx"'

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.