AnsiblePilot — Ansible Automation Platform and Enterprise Ansible

AnsiblePilot covers Red Hat Ansible Automation Platform (AAP) and enterprise Ansible: install and upgrade paths, Event-Driven Ansible, security and day-2 operations, plus Luca Berton's books, videos and training.

Popular Topics

About Luca Berton

Luca Berton is an Ansible automation expert, author of 9 technical books published by Apress and Leanpub, 4 of them on Ansible, including "Ansible for VMware by Examples" and "Ansible for Kubernetes by Example", and creator of the Ansible Pilot YouTube channel. He shares practical automation knowledge through tutorials, books, and video courses to help IT professionals and DevOps engineers master infrastructure automation.

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.
The public deadlines give the planning dates. The NIST plan in IR 8547 deprecates RSA and ECDSA after 2030 and disallows them after 2035. A certificate that is valid after those dates is on your list.

See also: Ansible: Audit Post-Quantum Readiness After the NSA Advisory (SSH, TLS, OpenSSL)

Prerequisites

ansible-galaxy collection install community.crypto

The 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:

  • find collects the certificate files. Change cert_paths for your applications.
  • x509_certificate_info reads each file. failed_when: false skips files that are not certificates, for example private keys with a .pem extension.
  • valid_at asks one question: is this certificate still valid on 1 January 2035?
  • public_key_type is RSA, ECC, Ed25519 or another type.
System CA bundles contain many public roots. They make the list long. To see only your own certificates, remove /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

FindingMeaningAction
RSA or ECC, expires in 90 daysNormal todayMake sure the renewal is automated
RSA or ECC, valid after 2035Long-lived trust anchorPlan the replacement; this is the slow work
Self-signed, long lifetimeUsually an internal CA or an applianceFind the owner
RSA below 2048 bitsWeak today, without a quantum computerReplace now
The second row is the reason to do the inventory early. Leaf certificates rotate in months. Roots, intermediate CAs and device certificates do not, and a replacement needs a new trust chain on each client.

See also: Renew and Change SSL/TLS Certificates in AAP 2.7: Operator-Based OpenShift Installation

What Comes Next

  1. Automate the renewal of each leaf certificate. Short lifetimes make the later algorithm change a routine change.
  2. Ask your CA, public or internal, for its ML-DSA plan.
  3. Run this playbook on a schedule and compare the reports.
The Ansible for Post-Quantum Cryptography guide covers the configuration changes for SSH, TLS and PKI.

Category: installation

Browse all Ansible tutorials · AnsiblePilot Home