mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-26 17:41:58 -06:00
Default Ansible EE provisioning to bundled Python
This commit is contained in:
34
Borealis.ps1
34
Borealis.ps1
@@ -467,7 +467,6 @@ function Ensure-AnsibleExecutionEnvironment {
|
|||||||
[Parameter(Mandatory = $true)]
|
[Parameter(Mandatory = $true)]
|
||||||
[string]$ProjectRoot,
|
[string]$ProjectRoot,
|
||||||
|
|
||||||
[Parameter(Mandatory = $true)]
|
|
||||||
[string]$PythonBootstrapExe,
|
[string]$PythonBootstrapExe,
|
||||||
|
|
||||||
[string]$RequirementsPath,
|
[string]$RequirementsPath,
|
||||||
@@ -475,11 +474,35 @@ function Ensure-AnsibleExecutionEnvironment {
|
|||||||
[string]$LogName = 'Install.log'
|
[string]$LogName = 'Install.log'
|
||||||
)
|
)
|
||||||
|
|
||||||
if (-not (Test-Path $PythonBootstrapExe -PathType Leaf)) {
|
$pythonBootstrap = $PythonBootstrapExe
|
||||||
Write-AgentLog -FileName $LogName -Message "[AnsibleEE] Bundled python executable missing at $PythonBootstrapExe"
|
if ([string]::IsNullOrWhiteSpace($pythonBootstrap) -or -not (Test-Path $pythonBootstrap -PathType Leaf)) {
|
||||||
throw "Bundled python executable not found for Ansible execution environment provisioning."
|
$bundleCandidate = Join-Path $ProjectRoot 'Dependencies\Python\python.exe'
|
||||||
|
if (Test-Path $bundleCandidate -PathType Leaf) {
|
||||||
|
$pythonBootstrap = $bundleCandidate
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($pythonBootstrap) -or -not (Test-Path $pythonBootstrap -PathType Leaf)) {
|
||||||
|
$pyCmd = Get-Command py -ErrorAction SilentlyContinue
|
||||||
|
if ($pyCmd -and (Test-Path $pyCmd.Source -PathType Leaf)) {
|
||||||
|
$pythonBootstrap = $pyCmd.Source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($pythonBootstrap) -or -not (Test-Path $pythonBootstrap -PathType Leaf)) {
|
||||||
|
$pythonCmd = Get-Command python -ErrorAction SilentlyContinue
|
||||||
|
if ($pythonCmd -and (Test-Path $pythonCmd.Source -PathType Leaf)) {
|
||||||
|
$pythonBootstrap = $pythonCmd.Source
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($pythonBootstrap) -or -not (Test-Path $pythonBootstrap -PathType Leaf)) {
|
||||||
|
Write-AgentLog -FileName $LogName -Message "[AnsibleEE] Unable to locate Python bootstrap executable."
|
||||||
|
throw "Python executable not found for Ansible execution environment provisioning."
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-AgentLog -FileName $LogName -Message "[AnsibleEE] Using Python bootstrap at $pythonBootstrap"
|
||||||
|
|
||||||
$eeRoot = Join-Path $ProjectRoot 'Agent\Ansible_EE'
|
$eeRoot = Join-Path $ProjectRoot 'Agent\Ansible_EE'
|
||||||
$metadataPath = Join-Path $eeRoot 'metadata.json'
|
$metadataPath = Join-Path $eeRoot 'metadata.json'
|
||||||
$versionTxtPath = Join-Path $eeRoot 'version.txt'
|
$versionTxtPath = Join-Path $eeRoot 'version.txt'
|
||||||
@@ -548,7 +571,7 @@ function Ensure-AnsibleExecutionEnvironment {
|
|||||||
}
|
}
|
||||||
New-Item -ItemType Directory -Force -Path $eeRoot | Out-Null
|
New-Item -ItemType Directory -Force -Path $eeRoot | Out-Null
|
||||||
|
|
||||||
& $PythonBootstrapExe -m venv $eeRoot | Out-Null
|
& $pythonBootstrap -m venv $eeRoot | Out-Null
|
||||||
if ($LASTEXITCODE -ne 0) {
|
if ($LASTEXITCODE -ne 0) {
|
||||||
Write-AgentLog -FileName $LogName -Message "[AnsibleEE] python -m venv failed with exit code $LASTEXITCODE"
|
Write-AgentLog -FileName $LogName -Message "[AnsibleEE] python -m venv failed with exit code $LASTEXITCODE"
|
||||||
throw "Failed to create Ansible execution environment virtual environment."
|
throw "Failed to create Ansible execution environment virtual environment."
|
||||||
@@ -580,6 +603,7 @@ function Ensure-AnsibleExecutionEnvironment {
|
|||||||
version = $expectedVersionNorm
|
version = $expectedVersionNorm
|
||||||
created_utc = (Get-Date).ToUniversalTime().ToString('o')
|
created_utc = (Get-Date).ToUniversalTime().ToString('o')
|
||||||
python = $pythonExe
|
python = $pythonExe
|
||||||
|
bootstrap_python = $pythonBootstrap
|
||||||
}
|
}
|
||||||
if ($requirementsHash) {
|
if ($requirementsHash) {
|
||||||
$metadata['requirements_hash'] = $requirementsHash
|
$metadata['requirements_hash'] = $requirementsHash
|
||||||
|
|||||||
Reference in New Issue
Block a user