iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
The reliable Ansible pattern is a two-pass ACME workflow: request the challenge, publish the HTTP-01 or DNS-01 proof, then call community.crypto.acme_certificate again with the registered challenge data. Store the resulting fullchain.pem and privkey.pem, reload the service only when the certificate changes, and test renewal before relying on it in production.
What you are automating
Let’s Encrypt issues TLS certificates through the Automated Certificate Management Environment (ACME) protocol. Its certificates are valid for 90 days, so issuance is only half the job: your automation must also detect certificates approaching expiry, complete validation again, deploy the new files, and reload the service that uses them.
On Ubuntu, Ansible can control that entire workflow without handing configuration ownership to a web-server plugin. The community.crypto.acme_certificate module is part of the separately installed community.crypto collection, not ansible-core. The module deliberately works in two passes:
- The first invocation creates or updates an ACME order and returns the challenge data.
- Your playbook publishes the returned proof where Let’s Encrypt can find it.
- The second invocation receives the registered result through
dataand downloads the certificate, chain, and full chain.
The two calls must use the same ACME account, CSR, domain set, and challenge type. Ansible’s documentation describes the requirement plainly: “To use this module, it has to be executed twice.”
#1 Best Overall
- Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
- Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
- Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
- Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
- 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
Choose HTTP-01 or DNS-01 first
The challenge determines what your network and playbook must be able to do. Use HTTP-01 when the requested names resolve to the Ubuntu host and inbound TCP port 80 can reach it. Use DNS-01 when port 80 cannot be exposed, when validation must happen independently of the web server, or when you need a wildcard name.
| Decision | HTTP-01 | DNS-01 |
|---|---|---|
| Proof location | A file under /.well-known/acme-challenge/ |
A TXT record under _acme-challenge |
| Inbound port 80 | Required | Not required |
| Wildcard certificates | Not supported | Required for names such as *.example.com |
| Automation dependency | Control of the webroot or a temporary standalone listener | Permission to create TXT records through your DNS provider’s API or equivalent |
| Typical complication | DNS or firewall sends the request elsewhere | Wrong DNS zone, slow propagation, or insufficient API permissions |
DNS-01 is also the only validation method that can obtain a wildcard certificate from Let’s Encrypt. A wildcard covers subdomains matching the pattern; it does not automatically cover the bare apex name, so request both example.com and *.example.com when both are needed.
Prerequisites on Ubuntu
- A registered domain whose DNS records are under your control.
- An Ubuntu host reachable by Ansible with privilege escalation available for writing certificate directories and reloading the service.
- A decision about the validation path. For HTTP-01, confirm that the public DNS A/AAAA records point to this host and that TCP port 80 is permitted through every firewall and load balancer. For DNS-01, confirm that the DNS provider can create TXT records and that the automation identity has the narrowest permissions needed.
- An ACME account key, kept separate from the private key for the certificate itself.
- A CSR containing every name that the certificate should contain.
Install the collection on the Ansible control node:
ansible-galaxy collection install community.crypto
If you intend to let Certbot handle renewal instead of having Ansible call the ACME module on a schedule, install Certbot using your chosen Ubuntu-supported method. The renewal details differ depending on how Certbot was installed; the twice-daily systemd timer discussed below applies to the snap installation.
Rank #2
- 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
- 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
- Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
- 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
- What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
Create and protect the ACME account key and CSR
The account key identifies your ACME account. The certificate private key proves possession of the certificate later. They should be different files, owned by root, and readable only by the processes that need them.
You can create the keys with the crypto collection. This example requests a certificate for the apex name and one wildcard name:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
- name: Create the ACME account key
community.crypto.openssl_privatekey:
path: /etc/letsencrypt/accounts/account.key
type: RSA
size: 4096
mode: '0600'
- name: Create the certificate private key
community.crypto.openssl_privatekey:
path: "/etc/letsencrypt/private/{{ le_domain }}.key"
type: RSA
size: 2048
mode: '0600'
- name: Create a CSR with all requested names
community.crypto.openssl_csr:
path: "/etc/letsencrypt/csr/{{ le_domain }}.csr"
privatekey_path: "/etc/letsencrypt/private/{{ le_domain }}.key"
common_name: "{{ le_domain }}"
subject_alt_name:
- "DNS:{{ le_domain }}"
- "DNS:*.{{ le_domain }}"
mode: '0644'
For a non-wildcard certificate, omit the wildcard SAN and list each additional hostname explicitly. Replacing a multi-domain certificate with a reduced name set is a common operational mistake: if you intend to replace the existing set, keep the complete set in the CSR and the ACME request.
Keep the account email in Ansible Vault or another secret-management system when policy requires it. Never print account keys, private keys, DNS API tokens, or complete module results in CI logs.
Rank #3
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
Build the two-pass Ansible workflow
The following skeleton uses HTTP-01 and a webroot. Set the ACME directory to the production Let’s Encrypt directory for live certificates; use the staging directory while developing to avoid production rate limits. The paths can be changed to match your service, but the certificate files should be placed in a directory with controlled ownership.
- name: Issue or renew a Let's Encrypt certificate
hosts: web
become: true
collections:
- community.crypto
vars:
le_domain: example.com
le_webroot: /var/www/html
acme_directory: https://acme-v02.api.letsencrypt.org/directory
account_key: /etc/letsencrypt/accounts/account.key
csr_file: "/etc/letsencrypt/csr/{{ le_domain }}.csr"
cert_file: "/etc/letsencrypt/live/{{ le_domain }}/cert.pem"
chain_file: "/etc/letsencrypt/live/{{ le_domain }}/chain.pem"
fullchain_file: "/etc/letsencrypt/live/{{ le_domain }}/fullchain.pem"
tasks:
- name: Ensure certificate directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: root
mode: '0755'
loop:
- /etc/letsencrypt/accounts
- /etc/letsencrypt/csr
- /etc/letsencrypt/live/{{ le_domain }}
- name: Request ACME challenge data
community.crypto.acme_certificate:
acme_directory: "{{ acme_directory }}"
account_key_src: "{{ account_key }}"
account_email: "tls-admin@example.com"
terms_agreed: true
challenge: http-01
csr: "{{ csr_file }}"
dest: "{{ cert_file }}"
chain_dest: "{{ chain_file }}"
fullchain_dest: "{{ fullchain_file }}"
remaining_days: 30
register: acme_order
- name: Create the challenge directory
ansible.builtin.file:
path: "{{ le_webroot }}/.well-known/acme-challenge"
state: directory
owner: root
group: root
mode: '0755'
# Publish the returned challenge values here.
# The exact loop is shown in the next section.
- name: Finalize the order and download the certificate
community.crypto.acme_certificate:
acme_directory: "{{ acme_directory }}"
account_key_src: "{{ account_key }}"
account_email: "tls-admin@example.com"
terms_agreed: true
challenge: http-01
csr: "{{ csr_file }}"
dest: "{{ cert_file }}"
chain_dest: "{{ chain_file }}"
fullchain_dest: "{{ fullchain_file }}"
data: "{{ acme_order }}"
remaining_days: 30
notify: Reload the TLS service
handlers:
- name: Reload the TLS service
ansible.builtin.service:
name: nginx
state: reloaded
remaining_days: 30 makes the run idempotent: an existing certificate with more than 30 days remaining does not trigger another issuance. Do not use forced issuance as a routine renewal strategy.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Fulfill HTTP-01 with a webroot
The first module result contains one or more challenge records. For each record, write its resource_value to the path formed from resource. Your web server must serve that file without authentication, application routing, or a redirect that strips the challenge path.
- name: Publish each HTTP-01 challenge
ansible.builtin.copy:
content: "{{ item.value.resource_value }}"
dest: "{{ le_webroot }}/.well-known/acme-challenge/{{ item.value.resource }}"
owner: root
group: root
mode: '0644'
loop: "{{ acme_order.challenge_data | dict2items }}"
when: acme_order.challenge_data is defined
- name: Verify that the challenge directory is reachable locally
ansible.builtin.uri:
url: "http://127.0.0.1/.well-known/acme-challenge/{{ item.value.resource }}"
return_content: true
status_code: 200
loop: "{{ acme_order.challenge_data | dict2items }}"
when: acme_order.challenge_data is defined
If several virtual hosts share the machine, use the webroot belonging to the names in the CSR and verify the public hostname, not only loopback. A successful local request does not prove that public DNS, a reverse proxy, a cloud firewall, and IPv6 routing all reach the same host.
Rank #4
- Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
- Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
- Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
- Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
- Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
Standalone validation is an alternative when no webroot is available, but the temporary listener must bind port 80. It fails if another service already occupies that port. Stop or coordinate the service during validation, or use webroot or DNS-01 instead.
Fulfill DNS-01 for wildcards or private HTTP infrastructure
For DNS-01, the first module result supplies a TXT value and the returned _acme-challenge name. Create every returned record in the authoritative zone, then wait for the provider’s changes to propagate before the second module call.
Recommended Free Tools
The DNS write itself is provider-specific, so use that provider’s Ansible module or an authenticated API task. Keep the API token in Ansible Vault, pass it to the module without displaying it, and grant permission only to the required zone and record type. Do not assume that the zone is the same as the full hostname: for www.example.com, the authoritative zone may be example.com or a delegated subzone.
Propagation time is variable. A fixed short pause can make an otherwise correct playbook flaky; prefer the provider’s wait facility or poll authoritative DNS until the exact TXT value is visible from outside the Ubuntu host. Remove obsolete challenge records after the order completes when your DNS provider and automation design permit it.
Best Value
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Change the module’s challenge value to dns-01, retain the same two-pass sequence, and make the second call only after every TXT record returned by the first call is published and observable.
Deploy the files safely
Ubuntu’s conventional live paths are:
/etc/letsencrypt/live/<domain>/fullchain.pemfor the server certificate followed by the intermediate chain./etc/letsencrypt/live/<domain>/privkey.pemfor the certificate private key.
The example keeps the private key at a separate path; configure the service to use the actual path produced by your playbook. Web servers normally need fullchain.pem, not only the leaf certificate, or clients may report an incomplete chain. Restrict private-key permissions, avoid copying keys into world-readable application directories, and verify that the service account can read the key without making it readable to unrelated users.
Reload only after the second ACME task changes the certificate. A reload handler avoids needless interruptions and ensures that a service does not continue using an old keypair after a successful renewal. After deployment, inspect the active listener with the service’s configuration test and an external TLS check; the files on disk can be new while the running process still has the previous certificate loaded.
Make renewal operational
Ansible-managed renewal
Schedule the playbook often enough to notice failures before the 90-day certificate expires, such as a daily systemd timer or an orchestrator job. The playbook should be safe to run repeatedly: retain remaining_days, leave existing files in place when no renewal is needed, and notify the service only when the module reports a change. Alert on failed runs and on certificates approaching expiry, rather than waiting for an outage.
Certbot-managed renewal
If Certbot owns the certificate, its snap installation creates a systemd renewal timer that runs twice daily. Test the complete path with:
sudo certbot renew --dry-run
A dry run verifies account access, validation, and renewal logic without replacing the production certificate. Certbot can reload services handled by its supported plugins, but services outside that integration need a deploy hook. The hook must reload or restart the consumer after a successful renewal; otherwise Certbot can report success while the public listener continues presenting the old certificate.
Free tools Windows power users keep installed
One-click scans. No signup required.
Do not make both Certbot and Ansible independently issue the same certificate without a clear ownership plan. Choose one renewal authority, document where it writes the files, and connect its change event to the service reload.
Quick Recap
Troubleshoot the common failures
| Symptom | Likely cause | What to check |
|---|---|---|
| HTTP-01 validation times out or returns the wrong content | DNS points elsewhere, port 80 is blocked, or a proxy routes the challenge to another webroot | Resolve every A and AAAA record, test the public URL, inspect firewall and load-balancer rules, and confirm the exact challenge file is served |
| Standalone mode cannot start | Another process already owns port 80 | Identify the listener, stop or coordinate it briefly, or switch to webroot or DNS-01 |
| DNS-01 remains pending | TXT record is in the wrong zone, has not propagated, or the API token cannot edit it | Query authoritative DNS for the exact name and value, inspect delegation, and review token permissions |
| Second module call reports missing challenge data | The registered result was not passed unchanged | Use data: "{{ acme_order }}" from the first call and keep the account, CSR, directory, and challenge consistent |
| Renewal succeeds but clients see the old certificate | The service was not reloaded or is reading a different path | Check the handler, service configuration, active listener, symlinks, and process reload logs |
| A replacement certificate loses names | The new CSR contains only a subset of the previous SANs | Include the complete intended domain set in the CSR and ACME request |
Production checklist
- DNS resolves every requested name to the intended validation path.
- The selected challenge matches the certificate scope; wildcard names use DNS-01.
community.cryptois installed on the control node and pinned according to your change-management policy.- The ACME account key and certificate private key are separate, protected, and backed up according to your recovery policy.
- The CSR contains the full intended SAN set.
- The first module call is registered, every challenge is fulfilled, and the second call passes the unchanged result through
data. - The service uses the full chain and the correct private key path.
- Reloads are change-triggered, not unconditional.
- A renewal dry run or equivalent scheduled Ansible run has succeeded, and alerts exist for failures and approaching expiry.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

