module_utils.manager package

Submodules

module_utils.manager.inventory module

class module_utils.manager.inventory.InventoryManager(role_path: Path, inventory_path: Path, vault_pw: str, overrides: Dict[str, str], allow_empty_plain: bool = False)

Bases: object

apply_schema() Dict

Apply the schema and return the updated inventory.

generate_secure_alphanumeric(length: int) str

Generate a cryptographically secure random alphanumeric string of the given length.

generate_value(algorithm: str) str

Generate a random secret value according to the specified algorithm.

Supported algorithms: • “random_hex”

– Returns a 64-byte (512-bit) secure random string, encoded as 128 hexadecimal characters. – Use when you need maximum entropy in a hex-only format.

  • “sha256”

    – Generates 32 random bytes, hashes them with SHA-256, and returns a 64-character hex digest. – Good for when you want a fixed-length (256-bit) hash output.

  • “sha1”

    – Generates 20 random bytes, hashes them with SHA-1, and returns a 40-character hex digest. – Only use in legacy contexts; SHA-1 is considered weaker than SHA-256.

  • “bcrypt”

    – Creates a random 16-byte URL-safe password, then applies a bcrypt hash. – Suitable for storing user-style passwords where bcrypt verification is needed.

  • “alphanumeric”

    – Produces a 64-character string drawn from [A–Z, a–z, 0–9]. – Offers ≈380 bits of entropy; human-friendly charset.

  • “base64_prefixed_32”

    – Generates 32 random bytes, encodes them in Base64, and prefixes the result with “base64:”. – Useful when downstream systems expect a Base64 format.

  • “random_hex_16”

    – Returns 16 random bytes (128 bits) encoded as 32 hexadecimal characters. – Handy for shorter tokens or salts.

Returns:

A securely generated string according to the chosen algorithm.

load_application_id(role_path: Path) str

Load the application ID from the role’s vars/main.yml file.

recurse_credentials(branch: dict, dest: dict, prefix: str = '')

Recursively process only the ‘credentials’ section and generate values.

Module contents