mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 19:21:58 -06:00
Use EE python to validate Ansible deps
This commit is contained in:
@@ -252,12 +252,42 @@ class Role:
|
|||||||
return os.path.join(tmp_dir, 'ansible_bootstrap.json')
|
return os.path.join(tmp_dir, 'ansible_bootstrap.json')
|
||||||
|
|
||||||
def _detect_missing_modules(self) -> dict:
|
def _detect_missing_modules(self) -> dict:
|
||||||
|
"""Return any required modules that the execution environment lacks."""
|
||||||
|
|
||||||
missing = {}
|
missing = {}
|
||||||
for module, spec in REQUIRED_MODULES.items():
|
|
||||||
try:
|
python_exe = _venv_python()
|
||||||
__import__(module)
|
if not python_exe or not os.path.isfile(python_exe):
|
||||||
except Exception:
|
missing['python'] = 'execution-environment python missing'
|
||||||
missing[module] = spec
|
return missing
|
||||||
|
|
||||||
|
module_names = sorted(REQUIRED_MODULES.keys())
|
||||||
|
probe = (
|
||||||
|
"import importlib.util, sys;"
|
||||||
|
f"mods={module_names!r};"
|
||||||
|
"missing=[m for m in mods if importlib.util.find_spec(m) is None];"
|
||||||
|
"sys.stdout.write('\\n'.join(missing))"
|
||||||
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
completed = subprocess.run(
|
||||||
|
[python_exe, '-c', probe],
|
||||||
|
check=True,
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
for name in module_names:
|
||||||
|
missing[name] = REQUIRED_MODULES[name]
|
||||||
|
return missing
|
||||||
|
|
||||||
|
stdout = (completed.stdout or '').strip()
|
||||||
|
if stdout:
|
||||||
|
for name in stdout.splitlines():
|
||||||
|
mod = name.strip()
|
||||||
|
if mod and mod in REQUIRED_MODULES:
|
||||||
|
missing[mod] = REQUIRED_MODULES[mod]
|
||||||
|
|
||||||
return missing
|
return missing
|
||||||
|
|
||||||
def _bootstrap_ansible_sync(self) -> bool:
|
def _bootstrap_ansible_sync(self) -> bool:
|
||||||
|
|||||||
Reference in New Issue
Block a user