Skip to content

Commit

Permalink
adding automated deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ned1313 committed Sep 12, 2018
1 parent 3aee10d commit b0682bf
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
8 changes: 7 additions & 1 deletion azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@
"azureAdminPassword": {
"type": "securestring"
},
"autoConfigureAzureAD": {
"type": "bool",
"defaultValue": true
},
"addressPrefix": {
"type": "string",
"defaultValue": "10.0.0.0/24",
Expand Down Expand Up @@ -145,6 +149,8 @@
"subnetRef": "[concat(variables('vnetID'), '/subnets/', parameters('subnetName'))]",
"scriptFileName": "post-config.ps1",
"scriptPath": "https://raw.githubusercontent.com/ned1313/AzureStack-VM-PoC/master/scripts/",
"scriptDefaultArgs" : "[concat(variables('scriptFileName'), ' ', variables('adminUsername'), ' ', parameters('adminPassword'))]",
"scriptAzureADArgs" : "[concat(variables('scriptDefaultArgs'), ' ', parameters('azureAdminUsername'), ' ', parameters('azureAdminPassword')]",
"fileUri": "[concat(variables('scriptPath'), variables('scriptFileName'))]",
"adminUsername": "__administrator",
"osDiskSizeinGB": 256,
Expand Down Expand Up @@ -231,7 +237,7 @@
"fileUris": [
"[variables('fileUri')]"
],
"commandToExecute": "[concat('powershell.exe -ExecutionPolicy Unrestricted -File ', variables('scriptFileName'), ' ', variables('adminUsername'), ' ', parameters('adminPassword'), ' ', parameters('azureAdminUsername'), ' ', parameters('azureAdminPassword'))]"
"commandToExecute": "[if(parameters('autoConfigureAzureAD'), concat('powershell.exe -ExecutionPolicy Unrestricted -File ', variables('scriptAzureADArgs')), concat('powershell.exe -ExecutionPolicy Unrestricted -File ', variables('scriptDefaultArgs')))]"
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions conditions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"testval" : {
"type": "bool",
"defaultValue": true
}
},
"resources": [
],
"outputs": {
"yesOutput": {
"type": "string",
"value": "[if(parameters('testval'), 'yes', 'no')]"
}
}
}
8 changes: 7 additions & 1 deletion scripts/Install-ASDK.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ $aadTenant = $AadAdminUser.Split("@")[1]
$localAdminCred = New-Object System.Management.Automation.PSCredential ($LocalAdminUsername, $localAdminPass)
$aadcred = New-Object System.Management.Automation.PSCredential ($AadAdminUser, $AadPassword)

Write-Log @writeLogParams -Message "Available ASDK versions found"
#Write-Log @writeLogParams -Message "Available ASDK versions found"
#Write-Log @writeLogParams -Message $versionArray

<#if ($version -eq $null)
Expand Down Expand Up @@ -209,6 +209,12 @@ if ($Interactive -eq $true)

#endregion

#Remove scheduled job from post-config.ps1 if present
if (Get-ScheduledJob -name "Install-ASDK" -ErrorAction SilentlyContinue)
{
Get-ScheduledJob -name "Install-ASDK" | Unregister-ScheduledJob -Force
}

#Test if ASDK required folder already in the OS drive
if ((Test-Path -Path ($foldersToCopy | ForEach-Object {Join-Path -Path $destPath -ChildPath $_})) -contains $false)
{
Expand Down
8 changes: 2 additions & 6 deletions scripts/post-config.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,6 @@ Set-ExecutionPolicy unrestricted -Force
#Download ASDK Downloader
Invoke-WebRequest -Uri "https://aka.ms/azurestackdevkitdownloader" -OutFile "D:\AzureStackDownloader.exe"

#Download and extract Mobaxterm
Invoke-WebRequest -Uri "https://aka.ms/mobaxtermLatest" -OutFile "$defaultLocalPath\Mobaxterm.zip"
Expand-Archive -Path "$defaultLocalPath\Mobaxterm.zip" -DestinationPath "$defaultLocalPath\Mobaxterm"
Remove-Item -Path "$defaultLocalPath\Mobaxterm.zip" -Force

#Install VS Code with ms-vscode.azure-account and msazurermtools.azurerm-vscode-tools
Invoke-WebRequest -Uri https://raw.githubusercontent.com/PowerShell/vscode-powershell/master/scripts/Install-VSCode.ps1 -OutFile "$scriptsPath\Install-VSCode.ps1"
Set-Location $scriptsPath
Expand Down Expand Up @@ -96,6 +91,7 @@ $argumentList = @{

$trigger = New-ScheduledTaskTrigger -AtStartup -AsJob

Register-ScheduledJob -Name "Install-ASDK" -FilePath $scriptsPath\Install-ASDK.ps1 -Trigger $trigger -ArgumentList $argumentList
$st = Register-ScheduledJob -Name "Install-ASDK" -FilePath $scriptsPath\Install-ASDK.ps1 -Trigger $trigger -ArgumentList $argumentList
#$st.StartJob()

Add-WindowsFeature Hyper-V, Failover-Clustering, Web-Server -IncludeManagementTools -Restart

0 comments on commit b0682bf

Please sign in to comment.