letsencrypt - Create SSL certificates with Let’s Encrypt

New in version 2.2.


  • Create and renew SSL certificates with Let’s Encrypt. Let’s Encrypt is a free, automated, and open certificate authority (CA), run for the public’s benefit. For details see The current implementation supports the http-01, tls-sni-02 and dns-01 challenges.
  • To use this module, it has to be executed at least twice. Either as two different tasks in the same run or during multiple runs.
  • Between these two tasks you have to fulfill the required steps for the chosen challenge by whatever means necessary. For http-01 that means creating the necessary challenge file on the destination webserver. For dns-01 the necessary dns record has to be created. tls-sni-02 requires you to create a SSL certificate with the appropriate subjectAlternativeNames. It is not the responsibility of this module to perform these steps.
  • For details on how to fulfill these challenges, you might have to read through
  • Although the defaults are chosen so that the module can be used with the Let’s Encrypt CA, the module can be used with any service using the ACME protocol.


parameter required default choices comments
The email address associated with this account.
It will be used for certificate expiration warnings.
File containing the the Let's Encrypt account RSA key.
Can be created with openssl rsa ....
The ACME directory to use. This is the entry point URL to access CA server API.
For safety reasons the default is set to the Let's Encrypt staging server. This will create technically correct, but untrusted certificates.
URI to a terms of service document you agree to when using the ACME service at acme_directory.
no http-01
  • http-01
  • dns-01
  • tls-sni-02
The challenge to be performed.
File containing the CSR for the new certificate.
Can be created with openssl csr ....
The CSR may contain multiple Subject Alternate Names, but each one will lead to an individual challenge that must be fulfilled for the CSR to be signed.

aliases: src
The data to validate ongoing challenges.
The value that must be used here will be provided by a previous use of this module.
The destination file for the certificate.

aliases: cert
no 10
The number of days the certificate must have left being valid. If cert_days < remaining_days, then it will be renewed. If the certificate is not renewed, module return values will not include challenge_data.


- letsencrypt:
    account_key: /etc/pki/cert/private/account.key
    csr: /etc/pki/cert/csr/
    dest: /etc/httpd/ssl/
  register: sample_com_challenge

# perform the necessary steps to fulfill the challenge
# for example:
# - copy:
#     dest: /var/www/html/{{ sample_com_challenge['challenge_data']['']['http-01']['resource'] }}
#     content: "{{ sample_com_challenge['challenge_data']['']['http-01']['resource_value'] }}"
#     when: sample_com_challenge|changed

- letsencrypt:
    account_key: /etc/pki/cert/private/account.key
    csr: /etc/pki/cert/csr/
    dest: /etc/httpd/ssl/
    data: "{{ sample_com_challenge }}"

Return Values

Common return values are documented here Return Values, the following are the fields unique to this module:

name description returned type sample
challenge_data per domain / challenge type challenge data changed dictionary
name description returned type sample
resource the challenge resource that must be created for validation changed string .well-known/acme-challenge/evaGxfADs6pSRb2LAv9IZf17Dt3juxGJ-PCt92wr-oA
resource_value the value the resource has to produce for the validation changed string IlirfxKKXA...17Dt3juxGJ-PCt92wr-oA
cert_days the number of days the certificate remains valid. success
authorizations ACME authorization data. changed list


This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.


This module is community maintained without core committer oversight.

For more information on what this means please read Module Support

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Helping Testing PRs and Developing Modules.