Files
computer-playbook/module_utils
Kevin Veen-Birkenbach d76e384ae3 Enhance CertUtils to return the newest matching certificate and add comprehensive unit tests
- Added run_openssl_dates() to extract notBefore/notAfter timestamps.
- Modified mapping logic to store multiple cert entries per SAN with metadata.
- find_cert_for_domain() now selects the newest certificate based on notBefore and mtime.
- Exact SAN matches take precedence over wildcard matches.
- Added new unit tests (test_cert_utils_newest.py) verifying freshness logic, fallback handling, and wildcard behavior.

Reference: https://chatgpt.com/share/68ef4b4c-41d4-800f-9e50-5da4b6be1105
2025-10-15 09:21:00 +02:00
..
2025-07-17 16:38:20 +02:00
2025-04-29 05:16:55 +02:00
2025-07-17 16:38:20 +02:00
2025-07-17 16:38:20 +02:00

Shared Utility Code (module_utils/) for Infinito.Nexus

This directory contains shared Python utility code (also known as "library code") for use by custom Ansible modules, plugins, or roles in the Infinito.Nexus project.

When to Use module_utils

  • Shared logic: Use module_utils to define functions, classes, or helpers that are shared across multiple custom modules, plugins, or filter/lookups in your project.
  • Reduce duplication: Centralize code such as API clients, input validation, complex calculations, or protocol helpers.
  • Maintainability: If you find yourself repeating code in different custom modules/plugins, refactor it into module_utils/.

Examples

  • Shared HTTP(S) connection handler for multiple modules.
  • Common validation or transformation functions for user input.
  • Utility functions for interacting with Docker, LDAP, etc.

Usage Example

In a custom Ansible module or plugin:

from ansible.module_utils.infinito_utils import my_shared_function

When not to Use module_utils

  • Do not place standalone Ansible modules or plugins here—those go into library/, filter_plugins/, or lookup_plugins/ respectively.
  • Only use for code that will be imported by other plugins or modules.

Further Reading