Ansible Q-Day Inventory: Find RSA and ECDSA Certificates Before Y2Q
By Luca Berton · Published 2026-12-05 · Category: installation
Q-Day is when quantum computers break RSA and ECDSA. Use Ansible and community.crypto to list every certificate, its key type and expiry before Y2Q.
Q-Day is the day a quantum computer can break RSA and elliptic-curve cryptography. Y2Q ("years to quantum") is the countdown. Nobody knows the date of Q-Day. But each of your certificates has a key type and an expiry date, and those tell you how much work you have.
This tutorial builds a certificate inventory with Ansible. It is read-only.
Why Certificates
Key exchange protects the session. You can move it to hybrid ML-KEM with an upgrade (see the post-quantum readiness audit). Certificates are different:
- They contain a signature algorithm, RSA or ECDSA today. A quantum computer can forge those signatures.
- They have long lifetimes. A root or an internal CA can be valid for 10 or 20 years.
- They are in many places: web servers, databases, message brokers, agents.
See also: Ansible: Audit Post-Quantum Readiness After the NSA Advisory (SSH, TLS, OpenSSL)
Prerequisites
ansible-galaxy collection install community.cryptoThe managed hosts need the Python cryptography library.
The Playbook
---
- name: Certificate inventory for Q-Day planning
hosts: all
become: true
gather_facts: false
vars:
cert_paths:
- /etc/ssl/certs
- /etc/pki/tls/certs
- /etc/letsencrypt/live
cert_patterns:
- "*.crt"
- "*.pem"
- "*.cer"
pqc_deadline: "20350101000000Z"
tasks:
- name: Find certificate files
ansible.builtin.find:
paths: "{{ cert_paths }}"
patterns: "{{ cert_patterns }}"
recurse: true
follow: true
file_type: any
register: cert_files
- name: Read each certificate
community.crypto.x509_certificate_info:
path: "{{ item.path }}"
valid_at:
after_deadline: "{{ pqc_deadline }}"
loop: "{{ cert_files.files }}"
loop_control:
label: "{{ item.path }}"
register: cert_info
failed_when: false
- name: Build the inventory for this host
ansible.builtin.set_fact:
cert_inventory: >-
{{ cert_inventory | default([]) + [{
'path': item.item.path,
'subject': item.subject.commonName | default(''),
'key_type': item.public_key_type,
'key_size': item.public_key_data.size | default(''),
'signature': item.signature_algorithm,
'not_after': item.not_after,
'self_signed': item.subject == item.issuer,
'valid_after_deadline': item.valid_at.after_deadline
}] }}
loop: "{{ cert_info.results }}"
loop_control:
label: "{{ item.item.path }}"
when: item.public_key_type is defined
- name: Show certificates that are valid after the deadline
ansible.builtin.debug:
msg: "{{ cert_inventory | default([]) | selectattr('valid_after_deadline') | list }}"How it works:
findcollects the certificate files. Changecert_pathsfor your applications.x509_certificate_inforeads each file.failed_when: falseskips files that are not certificates, for example private keys with a.pemextension.valid_atasks one question: is this certificate still valid on 1 January 2035?public_key_typeisRSA,ECC,Ed25519or another type.
/etc/ssl/certs from cert_paths and add your application directories.
See also: Ansible for Post-Quantum Cryptography: Migrate TLS, SSH & PKI (2026 Guide)
One Report for the Fleet
- name: Write the fleet report
hosts: localhost
gather_facts: false
tasks:
- name: Write the CSV file
ansible.builtin.copy:
dest: ./q-day-certificates.csv
mode: "0644"
content: |
host,path,subject,key_type,key_size,signature,not_after,self_signed,valid_after_2035
{% for h in groups['all'] %}
{% for c in hostvars[h].cert_inventory | default([]) %}
{{ h }},{{ c.path }},"{{ c.subject }}",{{ c.key_type }},{{ c.key_size }},{{ c.signature }},{{ c.not_after }},{{ c.self_signed }},{{ c.valid_after_deadline }}
{% endfor %}
{% endfor %}How to Read the Report
| Finding | Meaning | Action |
|---|---|---|
| RSA or ECC, expires in 90 days | Normal today | Make sure the renewal is automated |
| RSA or ECC, valid after 2035 | Long-lived trust anchor | Plan the replacement; this is the slow work |
| Self-signed, long lifetime | Usually an internal CA or an appliance | Find the owner |
| RSA below 2048 bits | Weak today, without a quantum computer | Replace now |
See also: Renew and Change SSL/TLS Certificates in AAP 2.7: Operator-Based OpenShift Installation
What Comes Next
- Automate the renewal of each leaf certificate. Short lifetimes make the later algorithm change a routine change.
- Ask your CA, public or internal, for its ML-DSA plan.
- Run this playbook on a schedule and compare the reports.
Related
Category: installation

Go deeper · Ebook by Luca Berton
Ansible for Security By Examples: get the ebook on Leanpub (opens in a new tab)
Automate security and compliance tasks with Ansible.
- Ebook
- Leanpub
- PDF & EPUB