Skip to content

Commit

Permalink
Support loading Python files with injected scope
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Feb 21, 2025
1 parent e727216 commit 1efb08d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions awx/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
factory,
export,
load_envvars,
load_python_file_with__injected_context,
load_standard_settings_files,
validate,
)
Expand Down Expand Up @@ -46,8 +47,12 @@
settings_dir = os.environ.get('AWX_SETTINGS_DIR', '/etc/tower/conf.d/')
settings_files_path = os.path.join(settings_dir, '*.py')
settings_file_path = os.environ.get('AWX_SETTINGS_FILE', '/etc/tower/settings.py')
DYNACONF.load_file(settings_file_path)
DYNACONF.load_file(settings_files_path)

# The following should have been loaded using `DYNACONF.load_file` but we are
# using `load_python_file_with__injected_context` to maintain backwards compatibility
load_python_file_with__injected_context(settings_files_path, settings=DYNACONF)
load_python_file_with__injected_context(settings_file_path, settings=DYNACONF)


# Load new standard settings files from
# /etc/ansible-automation-platform/ and /etc/ansible-automation-platform/awx/
Expand All @@ -56,9 +61,9 @@

# Load optional development only settings
if DYNACONF.get_environ("AWX_KUBE_DEVEL"):
DYNACONF.load_file("kube_defaults.py")
load_python_file_with__injected_context("kube_defaults.py", settings=DYNACONF)
else:
DYNACONF.load_file("local_*.py")
load_python_file_with__injected_context("local_*.py", settings=DYNACONF)

# Check at least one required setting file has been loaded
if "production" in DYNACONF.current_env.lower(): # pragma: no cover
Expand Down

0 comments on commit 1efb08d

Please # to comment.