Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
I set this up (both doing my own customizations and using your script verbatim) and both times I was met with this error:
FAILED! => {"changed": false, "msg": "ACME directory does not seem to follow protocol ACME v2", "other": {}}
Do you have any idea what the reason for that might be?
should be noted that letsencrypt is an alias to the acme_certificate module
Also probably should be using the openssl_privatekey and openssl_csr ansible modules for the creations of private keys and CSR. For one it’s pretty simple, for two every time you run a playbook the shell command is going ot run, regardless of whether the action has been run previously and does not need to be run.
https://docs.ansible.com/ansible/latest/modules/openssl_csr_module.html#openssl-csr-module
This tutorial is perfect to generate files, but not valid certificates. I can’t put it into Apache. The Browser not accpect, I got error SSL_ERROR_RX_RECORD_TOO_LONG with all generated certificates and keys.
Thanks, this is great for understanding what really happens behind Let’s Encrypt cert. But I prefer using CertBot more than acme_certificate module.
This setup guide is exactly what I was searching for! I’m so grateful that you laid out step by step instructions for provisioning a cert using the actual acme_certificate path rather than offloading this to use apt install certbot.
One suggestion, is it possible to update the host server with a Cron job to request new certificates automatically? This eliminates the need to re run the playbook every 90 days.
What is the purpose of including the domain in the acme_challenge_my-domain variable? Couldn’t it just be called “acme_challenge”?
What about cleaning up the files in .well-known/acme-challenge? Perhaps we should delete the acme-challenge folder before creating it each time?
@jamieweb If the playbook run once it’s working but when I run the playbook again I get this error
fatal: [test_server]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'domain.me'\n\nThe error appears to be in '/Users/name/Desktop/test_ansible/ansible/staging/roles/letsencrypt/tasks/main.yml': line 60, column 5, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n - name: \"Implement http-01 challenge files\"\n ^ here\n"}
Apparently, it’s coming from this task:
- name: "Implement http-01 challenge files"
copy:
content: "{{ acme_challenge_domain_me['challenge_data'][item]['http-01']['resource_value'] }}"
dest: "/var/www/{{domain_name}}/{{ acme_challenge_domain_me['challenge_data'][item]['http-01']['resource'] }}"
owner: root
group: root
mode: u=rw,g=r,o=r
with_items:
- "{{ domain_name }}"
- "www.{{ domain_name }}"
Could you shine some light?
The second letsencrypt command should probably also have a remaining_days. In my code after the challenge was accepted, it did not renew when expected until I added the line. I believe that’s because the first one doesn’t generate the cert, lacking the data parameter.
PS - This is an amazing article. Very clear and easy to work from. Thanks for writing it!
Thank you for this tutorial. I had a problem finding the letsencrypt module and learned that it has been renamed to acme_certificate. Everything seems to be working now that I’ve updated my ansible playbook. Thanks again!