Skip to content

Commit

Permalink
Enhanced lab scripts (dsccommunity#162)
Browse files Browse the repository at this point in the history
* Imrpoved software deployment code + formatting.

* Updated ISO names

* Fixed formatting in lab scripts
  • Loading branch information
raandree authored Nov 21, 2023
1 parent 895cab4 commit b119d6b
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 101 deletions.
4 changes: 2 additions & 2 deletions Lab/00 Lab Deployment.ps1
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
param (
[Parameter(Mandatory)]
[Parameter(Mandatory = $true)]
[ValidateSet('Azure', 'HyperV')]
[string]
$HostType
)

Import-Module -Name AutomatedLab, AutomatedLab.Common -ErrorAction Stop

$files = dir -Path $PSScriptRoot -File | Where-Object Name -NotLike 00*
$files = Get-ChildItem -Path $PSScriptRoot -File | Where-Object Name -NotLike 00*
$files = $files | Where-Object { $_ -ne ($files | Where-Object { $_.Name -like '10*' -and $_.Name -notlike "10 $HostType*" }) }

foreach ($file in $files)
Expand Down
4 changes: 2 additions & 2 deletions Lab/10 Azure Full Lab with DSC and AzureDevOps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Some
Set-LabInstallationCredential -Username Install -Password Somepass1

# Add the reference to our necessary ISO files
Add-LabIsoImageDefinition -Name AzDevOps -Path $labSources\ISOs\mul_azure_devops_server_2022_x64_dvd_9d49a4d6.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops
Add-LabIsoImageDefinition -Name AzDevOps -Path $labSources\ISOs\azuredevops2022.0.1.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops

# Data Disks
Add-LabDiskDefinition -Name DSCDO01_D -DiskSizeInGb 120 -Label DataDisk1 -DriveLetter D
Expand Down Expand Up @@ -66,7 +66,7 @@ $roles = @(
Get-LabMachineRoleDefinition -Role TfsBuildWorker -Properties @{ NumberOfBuildWorkers = '4' }
Get-LabMachineRoleDefinition -Role HyperV
)
Add-LabMachineDefinition -Name DSCHost01 -Memory 8GB -Roles $roles -IpAddress 192.168.111.80 -DiskName DSCHost01_D -AzureProperties @{RoleSize = 'Standard_D4s_v3'}
Add-LabMachineDefinition -Name DSCHost01 -Memory 8GB -Roles $roles -IpAddress 192.168.111.80 -DiskName DSCHost01_D -AzureProperties @{RoleSize = 'Standard_D4s_v3' }

# DSC target nodes - our legacy VMs with an existing configuration
Add-LabMachineDefinition -Name DSCFile01 -Memory 1GB -Roles FileServer -IpAddress 192.168.111.100
Expand Down
2 changes: 1 addition & 1 deletion Lab/10 HyperV Full Lab with DSC and AzureDevOps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Some
Set-LabInstallationCredential -Username Install -Password Somepass1

# Add the reference to our necessary ISO files
Add-LabIsoImageDefinition -Name AzDevOps -Path $labSources\ISOs\mul_azure_devops_server_2022_x64_dvd_9d49a4d6.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops
Add-LabIsoImageDefinition -Name AzDevOps -Path $labSources\ISOs\azuredevops2022.0.1.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops
Add-LabIsoImageDefinition -Name SQLServer2019 -Path $labsources\ISOs\SQLServer2019-x64-ENU.iso #from https://www.microsoft.com/en-us/evalcenter/evaluate-sql-server-2019. The EXE downloads the ISO.

# Data Disks
Expand Down
197 changes: 123 additions & 74 deletions Lab/20 Lab Customizations.ps1

Large diffs are not rendered by default.

41 changes: 41 additions & 0 deletions Lab/20 SoftwarePackages.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
$softwarePackages = @{
VsCode = @{
Url = 'https://az764295.vo.msecnd.net/stable/704ed70d4fd1c6bd6342c436f1ede30d1cff4710/VSCodeSetup-x64-1.77.3.exe'
CommandLine = '/VERYSILENT /MERGETASKS=!runcode'
Roles = 'AzDevOps'
}
Git = @{
Url = 'https://github.com/git-for-windows/git/releases/download/v2.40.0.windows.1/Git-2.40.0-64-bit.exe'
CommandLine = '/SILENT'
Roles = 'AzDevOps'
}
NotepadPlusPlus = @{
Url = 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.5.1/npp.8.5.1.Installer.x64.exe'
CommandLine = '/S'
Roles = 'All'
}
PowerShell7 = @{
Url = 'https://github.com/PowerShell/PowerShell/releases/download/v7.3.3/PowerShell-7.3.3-win-x64.msi'
CommandLine = '/quiet'
Roles = 'AzDevOps'
}
Dotnet7Sdk = @{
Url = 'https://download.visualstudio.microsoft.com/download/pr/89a2923a-18df-4dce-b069-51e687b04a53/9db4348b561703e622de7f03b1f11e93/dotnet-sdk-7.0.203-win-x64.exe'
CommandLine = '/install /quiet /norestart'
Roles = 'AzDevOps'
}
DotNetCoreRuntime = @{
Url = 'https://download.visualstudio.microsoft.com/download/pr/b92958c6-ae36-4efa-aafe-569fced953a5/1654639ef3b20eb576174c1cc200f33a/windowsdesktop-runtime-3.1.32-win-x64.exe'
CommandLine = '/install /quiet /norestart'
Roles = 'AzDevOps'
}
'7zip' = @{
Url = 'https://7-zip.org/a/7z2201-x64.exe'
CommandLine = '/S'
Roles = 'All'
}
VsCodePowerShellExtension = @{
Url = 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/PowerShell/2023.4.0/vspackage'
DestinationFolder = 'VSCodeExtensions'
}
}
4 changes: 2 additions & 2 deletions Lab/31 New Release Pipeline DscConfig.Demo.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ $collectionName = 'AutomatedLab'
$gitVersion = @{
Publisher = 'GitTools'
Extension = 'GitVersion'
Version = '5.0.1.3'
VsixPath = 'C:\gittools.gitversion-5.0.1.3.vsix'
Version = '5.0.1.3'
VsixPath = 'C:\gittools.gitversion-5.0.1.3.vsix'
}
$lab = Get-Lab
$devOpsServer = Get-LabVM -Role AzDevOps
Expand Down
20 changes: 15 additions & 5 deletions Lab/32 New Release Pipeline DscWorkshop.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
if (-not (Get-Lab -ErrorAction SilentlyContinue).Name -eq 'DscWorkshop') {
if (-not (Get-Lab -ErrorAction SilentlyContinue).Name -eq 'DscWorkshop')
{
Import-Lab -Name DscWorkshop -NoValidation -ErrorAction Stop
}

Expand All @@ -8,19 +9,28 @@ $collectionName = 'AutomatedLab'

$lab = Get-Lab
$devOpsServer = Get-LabVM -Role AzDevOps
$devOpsHostName = if ($lab.DefaultVirtualizationEngine -eq 'Azure') { $devOpsServer.AzureConnectionInfo.DnsName } else { $devOpsServer.FQDN }
$devOpsHostName = if ($lab.DefaultVirtualizationEngine -eq 'Azure')
{
$devOpsServer.AzureConnectionInfo.DnsName
}
else
{
$devOpsServer.FQDN
}
$nugetServer = Get-LabVM -Role AzDevOps
$nugetFeed = Get-LabTfsFeed -ComputerName $nugetServer -FeedName PowerShell
$pullServer = Get-LabVM -Role DSCPullServer
$hypervHost = Get-LabVM -Role HyperV

$devOpsRole = $devOpsServer.Roles | Where-Object Name -like AzDevOps
$devOpsRole = $devOpsServer.Roles | Where-Object Name -Like AzDevOps
$devOpsCred = $devOpsServer.GetCredential($lab)
$devOpsPort = $originalPort = 8080
if ($devOpsRole.Properties.ContainsKey('Port')) {
if ($devOpsRole.Properties.ContainsKey('Port'))
{
$devOpsPort = $devOpsRole.Properties['Port']
}
if ($lab.DefaultVirtualizationEngine -eq 'Azure') {
if ($lab.DefaultVirtualizationEngine -eq 'Azure')
{
$devOpsPort = (Get-LabAzureLoadBalancedPort -DestinationPort $devOpsPort -ComputerName $devOpsServer).Port
}

Expand Down
2 changes: 1 addition & 1 deletion Lab/33 Install DscAutoOnboarding.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Invoke-LabCommand -ActivityName "Removing DSC nodes from config data for onboard
git clone https://contoso\install:Somepass1@dscdo01:8080/AutomatedLab/DscWorkshop/_git/DscWorkshop $temp 2>&1 | Out-Null
Push-Location -Path $temp

Rename-Item .\DSC\DscConfigData\AllNodes\ -NewName BackupAllNodes
Rename-Item .\DSC\DscConfigData\AllNodes\ -NewName BackupAllNodes
git add .
git commit -m "Removed all DSC demo nodes for 'DscAutoOnboardingEndpoint' by renaming 'AllNodes' folder" | Out-Null
$result = git push 2>&1
Expand Down
5 changes: 3 additions & 2 deletions Lab/40 SQL Server Reporting DB.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Install-LabSoftwarePackage -Path $labsources\SoftwarePackages\SQLServerReporting

Invoke-LabCommand -ActivityName 'Configuring SSRS' -ComputerName $sqlServer -FilePath $labSources\PostInstallationActivities\SqlServer\SetupSqlServerReportingServices.ps1

if (-not (Get-Module -Name ReportingServicesTools -ListAvailable)) {
if (-not (Get-Module -Name ReportingServicesTools -ListAvailable))
{
Install-Module -Name ReportingServicesTools -Force
}
$s = New-LabPSSession -ComputerName $sqlServer
Expand All @@ -27,4 +28,4 @@ Invoke-LabCommand -ActivityName 'Add DSC Reports to Reporting Server' -ComputerN
}

Checkpoint-LabVM -All -SnapshotName AfterSqlReporting
Write-Host "4. - Creating Snapshot 'AfterSqlReporting'" -ForegroundColor Magenta
Write-Host "4. - Creating Snapshot 'AfterSqlReporting'" -ForegroundColor Magenta
24 changes: 12 additions & 12 deletions Lab/50 HyperV Host.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Invoke-LabCommand -ActivityName 'Install AutomatedLab and create LabSources folder' -ComputerName $hosts -ScriptBlock {
if ($PSVersionTable.PSVersion.Major -lt 6 -and [Net.ServicePointManager]::SecurityProtocol -notmatch 'Tls12')
{
Write-Verbose -Message 'Adding support for TLS 1.2'
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
Write-Verbose -Message 'Adding support for TLS 1.2'
[Net.ServicePointManager]::SecurityProtocol += [Net.SecurityProtocolType]::Tls12
}

#Add the AutomatedLab Telemetry setting to default to allow collection, otherwise will prompt during installation
Expand All @@ -13,11 +13,11 @@ Invoke-LabCommand -ActivityName 'Install AutomatedLab and create LabSources fold
Install-Module -Name AutomatedLab -AllowClobber -Force -ErrorAction Stop

Import-Module -Name AutomatedLab -ErrorAction Stop

Enable-LabHostRemoting -Force

New-LabSourcesFolder -ErrorAction Stop

Set-PSFConfig -Name MacAddressPrefix -Module AutomatedLab -Value 1017FB -PassThru | Register-PSFConfig -Scope UserDefault
}

Expand All @@ -29,26 +29,26 @@ Invoke-LabCommand -ActivityName 'Setup Test VM' -ComputerName $hosts -ScriptBloc
[System.Environment]::SetEnvironmentVariable('AUTOMATEDLAB_TELEMETRY_OPTOUT', '0')
Import-Module -Name AutomatedLab
$dc = Get-ADDomainController

$netAdapter = Get-NetAdapter -Name 'vEthernet (AlExternal)' -ErrorAction SilentlyContinue
if (-not $netAdapter)
{
$netAdapter = Get-NetAdapter -Name Ethernet -ErrorAction SilentlyContinue
}

$ip = $netAdapter | Get-NetIPAddress -AddressFamily IPv4

#--------------------------------

New-LabDefinition -Name Lab1 -DefaultVirtualizationEngine HyperV
$os = Get-LabAvailableOperatingSystem | Where-Object { $_.OperatingSystemName -like '*Datacenter*' -and $_.OperatingSystemName -like '*2019*' -and $_.OperatingSystemName -like '*Desktop*' }

Add-LabVirtualNetworkDefinition -Name AlExternal -AddressSpace "$($ip.IPAddress)/$($ip.PrefixLength)" -HyperVProperties @{ SwitchType = 'External'; AdapterName = 'Ethernet' }

Add-LabMachineDefinition -Name $dc.Name -Memory 1GB -OperatingSystem $os -Roles RootDC -DomainName $dc.Domain -IpAddress $dc.IPv4Address -SkipDeployment
Add-LabMachineDefinition -Name TestVM1 -Memory 1GB -OperatingSystem $os -DomainName $dc.Domain -DnsServer1 $dc.IPv4Address -Gateway (Get-NetIPConfiguration).IPv4DefaultGateway.NextHop

Install-Lab

Show-LabDeploymentSummary -Detailed
}

0 comments on commit b119d6b

Please sign in to comment.