Files
computer-playbook/utils
kevinveenbirkenbachandClaude Opus 5 1613e73e6b fix(variants): read a templated enabled flag per the caller's scope
_is_enabled treated an `enabled` that is a Jinja template rather than a
literal as running. That is the safe reading wherever an under-count would
hide a service, but it is the wrong one for the budget guard, which scores a
single variant: a variant that means to run a dynamically flagged service
pins it to a literal true, because the bond guard requires exactly that. The
guard therefore charged a variant for services that variant never starts,
and the sum crossed the 64GB ceiling on a role that fits.

The predicate takes a third parameter instead of choosing for everyone. It
defaults to the previous reading, so every existing caller is unchanged, and
collect_role_resources threads it through its recursion so one scope is read
the same way at every depth. The only caller that passes False is the budget
guard.

The two readings are observably different rather than theoretical: resolving
svc-ai-agent-broker yields 31 roles under the default and 6 under the
variant-scoped reading.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-24 16:24:17 +02:00
..
…
…
…
…

Shared Utilities (utils/)

This directory contains shared Python helpers used by custom modules and plugins.

Purpose

Use utils/ for reusable code that should not be duplicated across:

  • library/ modules,
  • plugins/action/,
  • plugins/filter/,
  • plugins/lookup/.

Typical shared utilities:

  • API clients,
  • validation/conversion helpers,
  • path and configuration helpers,
  • cross-plugin/module domain logic.
  • Shared HTTP(S) connection handler for multiple modules.
  • Common validation or transformation functions for user input.
  • Utility functions for interacting with Docker, LDAP, etc.
  • Grouped helper packages such as utils/domains/ for related domain logic.

Design Guidelines

  • Keep helpers focused and composable.
  • Avoid side effects during import.
  • Prefer explicit function/class APIs over implicit globals.
  • Keep dependencies minimal so modules/plugins stay lightweight.

Example Import

from utils.domains.primary_domain import get_primary_domain

What Does Not Belong Here

  • Standalone executable modules (put in library/).
  • Ansible plugin entrypoints (put in plugins/*).

References