Files
computer-playbook/module_utils
Kevin Veen-Birkenbach ed73a37795 Improve get_app_conf robustness and add skip_missing_app parameter support
- Added new optional parameter 'skip_missing_app' to get_app_conf() in module_utils/config_utils.py to safely return defaults when applications are missing.
- Updated group_vars/all/00_general.yml and roles/web-app-nextcloud/config/main.yml to include skip_missing_app=True in all Nextcloud-related calls.
- Added comprehensive unit tests under tests/unit/module_utils/test_config_utils.py covering missing app handling, schema enforcement, nested lists, and index edge cases.

Ref: https://chatgpt.com/share/68ee6b5c-6db0-800f-bc20-d51470d7b39f
2025-10-14 17:25:37 +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