Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arcbox 3.0 - Fix waiting for vm restart #2641

Merged
merged 11 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
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
33 changes: 24 additions & 9 deletions azure_jumpstart_arcbox/artifacts/ArcServersLogonScript.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,20 @@ if ($Env:flavor -ne "DevOps") {

# Restarting Windows VM Network Adapters
Write-Host "Restarting Network Adapters"
Start-Sleep -Seconds 20
Invoke-Command -VMName $SQLvmName -ScriptBlock { Get-NetAdapter | Restart-NetAdapter } -Credential $winCreds
Start-Sleep -Seconds 5
Invoke-Command -VMName $SQLvmName -ScriptBlock { Get-NetAdapter | Restart-NetAdapter } -Credential $winCreds
Start-Sleep -Seconds 20

Write-Header "Renaming the nested SQL VM"
Invoke-Command -VMName $SQLvmName -ScriptBlock { Rename-Computer -NewName $using:SQLvmName -Restart } -Credential $winCreds
Invoke-Command -VMName $SQLvmName -ScriptBlock { Rename-Computer -NewName $using:SQLvmName -Restart} -Credential $winCreds

do {
$sqlVMStatus=(Get-VM $SQLvmName | Select-Object networkAdapters -ExpandProperty networkadapters).IPAddresses
Write-Host "Waiting for the nested SQL VM to come back online...waiting for 10 seconds"
Start-Sleep -Seconds 10
}until($sqlVMStatus -ne "")

Start-Sleep -Seconds 15
Start-Sleep -Seconds 10

# Download SQL assessment preparation script
Invoke-WebRequest ($Env:templateBaseUrl + "artifacts/prepareSqlServerForAssessment.ps1") -OutFile $nestedVMArcBoxDir\prepareSqlServerForAssessment.ps1
Expand Down Expand Up @@ -404,10 +410,10 @@ $payLoad = @"

# Restarting Windows VM Network Adapters
Write-Header "Restarting Network Adapters"
Start-Sleep -Seconds 20
Start-Sleep -Seconds 5
Invoke-Command -VMName $Win2k19vmName -ScriptBlock { Get-NetAdapter | Restart-NetAdapter } -Credential $winCreds
Invoke-Command -VMName $Win2k22vmName -ScriptBlock { Get-NetAdapter | Restart-NetAdapter } -Credential $winCreds
Start-Sleep -Seconds 5
Start-Sleep -Seconds 10

# Renaming the nested VMs
Write-Header "Renaming the nested Windows VMs"
Expand All @@ -422,9 +428,18 @@ $payLoad = @"
Write-Output "Renaming the nested Linux VMs"
$ubuntuSession = New-SSHSession -ComputerName $Ubuntu01VmIp -Credential $linCreds -Force -WarningAction SilentlyContinue
$Command = "sudo hostnamectl set-hostname $ubuntu01vmName;sudo systemctl reboot"
$(Invoke-SSHCommand -SSHSession $ubuntuSession -Command $Command -Timeout 600 -WarningAction SilentlyContinue).Output

Start-Sleep -Seconds 15
$(Invoke-SSHCommand -SSHSession $ubuntuSession -Command $Command -Timeout 900 -WarningAction SilentlyContinue).Output

do {
$win2k19Status=(Get-VM $Win2k19vmName | Select-Object networkAdapters -ExpandProperty networkadapters).IPAddresses
$win2k22Status=(Get-VM $Win2k19vmName | Select-Object networkAdapters -ExpandProperty networkadapters).IPAddresses
$ubuntu01Status = (Get-VM $ubuntu01vmName | Select-Object networkAdapters -ExpandProperty networkadapters).IPAddresses
$ubuntu02Status = (Get-VM $ubuntu02vmName | Select-Object networkAdapters -ExpandProperty networkadapters).IPAddresses
Write-Host "Waiting for the nested VMs to come back online...waiting for 10 seconds"
Start-Sleep -Seconds 10
}until($win2k19Status -ne "" -and $win2k22Status -ne "" -and $ubuntu01Status -ne "" -and $ubuntu02Status -ne "")

Start-Sleep -Seconds 10

# Copy installation script to nested Windows VMs
Write-Output "Transferring installation script to nested Windows VMs..."
Expand Down
4 changes: 2 additions & 2 deletions azure_jumpstart_arcbox/bicep/mgmt/policyAzureArc.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ resource policy_tagging_resources 'Microsoft.Authorization/roleAssignments@2020-
}]

resource updateManagerArcPolicyLinux 'Microsoft.Authorization/policyAssignments@2024-04-01' = {
name: '(ArcBox) Enable Azure Update Manager for Arc-enabled Linux machines'
name: '(ArcBox) Enable Azure Update Manager for Linux hybrid machines'
location: azureLocation
scope: resourceGroup()
identity: {
Expand All @@ -148,7 +148,7 @@ resource updateManagerArcPolicyLinux 'Microsoft.Authorization/policyAssignments@
}

resource updateManagerArcPolicyWindows 'Microsoft.Authorization/policyAssignments@2024-04-01' = {
name: '(ArcBox) Enable Azure Update Manager for Arc-enabled Windows machines'
name: '(ArcBox) Enable Azure Update Manager for Windows hybrid machines'
location: azureLocation
scope: resourceGroup()
identity: {
Expand Down
Loading