Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ansible_base/lib/dynamic_config/dynaconf_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import inspect
import os
import sys
from contextlib import suppress
from pathlib import Path
from typing import Any
from warnings import warn
Expand Down Expand Up @@ -269,6 +270,13 @@ def load_python_file_with_injected_context(*paths: str, settings: Dynaconf, run_
files_to_load = glob(pattern)
for file_path in files_to_load:
scope = settings.as_dict()

# Inject ldap module because some legacy custom config expect it on the global scope
with suppress(ImportError): # ldap may not be installed on all environments
import ldap

scope["ldap"] = ldap

file_path = os.path.abspath(file_path)
with open(file_path, "rb") as to_compile:
code = compile(to_compile.read(), file_path, "exec")
Expand Down
Loading