Skip to content

Commit 6c35c12

Browse files
committed
Run the bootstrap script AFTER the buildkite-agent user is created
This allows end-users to reference the buildkite-agent user in their bootscript to handle things like setting file/folder permissions. Signed-off-by: Tom Duffield <[email protected]>
1 parent 46d94b6 commit 6c35c12

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packer/windows/conf/bin/bk-install-elastic-stack.ps1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ disconnect-after-job=${Env:BUILDKITE_TERMINATE_INSTANCE_AFTER_JOB}
9494
"@
9595
$OFS=" "
9696

97-
If (![string]::IsNullOrEmpty($Env:BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT)) {
98-
C:\buildkite-agent\bin\bk-fetch.ps1 -From "$Env:BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT" -To C:\buildkite-agent\elastic_bootstrap.ps1
99-
C:\buildkite-agent\elastic_bootstrap.ps1
100-
Remove-Item -Path C:\buildkite-agent\elastic_bootstrap.ps1
101-
}
102-
10397
nssm set lifecycled AppEnvironmentExtra :AWS_REGION=$Env:AWS_REGION
10498
nssm set lifecycled AppEnvironmentExtra +LIFECYCLED_HANDLER="C:\buildkite-agent\bin\stop-agent-gracefully.ps1"
10599
Restart-Service lifecycled
@@ -133,6 +127,15 @@ If ($Env:BUILDKITE_WINDOWS_ADMINISTRATOR -eq "true") {
133127
Add-LocalGroupMember -Group "Administrators" -Member $UserName | out-null
134128
}
135129

130+
If (![string]::IsNullOrEmpty($Env:BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT)) {
131+
Write-Output "Running the elastic bootstrap script"
132+
C:\buildkite-agent\bin\bk-fetch.ps1 -From "$Env:BUILDKITE_ELASTIC_BOOTSTRAP_SCRIPT" -To C:\buildkite-agent\elastic_bootstrap.ps1
133+
C:\buildkite-agent\elastic_bootstrap.ps1
134+
Remove-Item -Path C:\buildkite-agent\elastic_bootstrap.ps1
135+
}
136+
137+
Write-Output "Starting the Buildkite Agent"
138+
136139
nssm install buildkite-agent C:\buildkite-agent\bin\buildkite-agent.exe start
137140
nssm set buildkite-agent ObjectName .\$UserName $Password
138141
nssm set buildkite-agent AppStdout C:\buildkite-agent\buildkite-agent.log

0 commit comments

Comments
 (0)