Skip to content

Commit

Permalink
Merge pull request #153 from raandree/fix/LabSetup
Browse files Browse the repository at this point in the history
Fixed the lab environment
  • Loading branch information
nyanhp authored Apr 3, 2023
2 parents 60949c4 + 35d6a22 commit f24fbc3
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 49 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]

### Added

- Added stages to cloud pipeline and added steps to publish modules to Azure Automation DSC.

### Changed
Expand All @@ -15,7 +16,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Changed from 'CommonTasks' to 'DscConfig.Demo' for faster build time.

### Fixed
- Config data test 'No duplicate IP addresses should be used' threw when there

- Config data test 'No duplicate IP addresses should be used' threw when there.
is no IP address configured.
- Module versions incremented.
- Fix typo in ConfigData tests.
Expand Down
32 changes: 17 additions & 15 deletions Lab/10 Azure Full Lab with DSC and AzureDevOps.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
$labName = "DscWorkshop_$((1..6 | ForEach-Object { [char[]](97..122) | Get-Random }) -join '')"
$azureLocation = 'West Europe'

#region Lab setup
#--------------------------------------------------------------------------------------------------------------------
#----------------------- CHANGING ANYTHING BEYOND THIS LINE SHOULD NOT BE REQUIRED ----------------------------------
#----------------------- + EXCEPT FOR THE LINES STARTING WITH: REMOVE THE COMMENT TO --------------------------------
#----------------------- + EXCEPT FOR THE LINES CONTAINING A PATH TO AN ISO OR APP --------------------------------
#--------------------------------------------------------------------------------------------------------------------

#create an empty lab template and define where the lab XML files and the VMs will be stored
# Create an empty lab template and define where the lab XML files and the VMs will be stored
New-LabDefinition -Name $labName -DefaultVirtualizationEngine Azure
Add-LabAzureSubscription -DefaultLocationName $azureLocation

#make the network definition
# Make the network definition
Add-LabVirtualNetworkDefinition -Name $labName -AddressSpace 192.168.111.0/24

#and the domain definition with the domain admin account
# and the domain definition with the domain admin account
Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Somepass1

#these credentials are used for connecting to the machines. As this is a lab we use clear-text passwords
# these credentials are used for connecting to the machines. As this is a lab we use clear-text passwords
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_2020.1.1_x64_dvd_b97c496e.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops
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

#defining default parameter values, as these ones are the same for all the machines
# Data Disks
Add-LabDiskDefinition -Name DSCDO01_D -DiskSizeInGb 120 -Label DataDisk1 -DriveLetter D
Add-LabDiskDefinition -Name DSCHost01_D -DiskSizeInGb 120 -Label DataDisk1 -DriveLetter D

# Defining default parameter values, as these ones are the same for all the machines
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:Network' = $labName
'Add-LabMachineDefinition:ToolsPath' = "$labSources\Tools"
Expand All @@ -50,20 +53,20 @@ $roles = @(
SqlServer = 'DSCCASQL01'
DatabaseName = 'DSC'
}
Get-LabMachineRoleDefinition -Role TfsBuildWorker -Properties @{ NumberOfBuildWorkers = '4' }
#Get-LabMachineRoleDefinition -Role TfsBuildWorker -Properties @{ NumberOfBuildWorkers = '4' }
Get-LabMachineRoleDefinition -Role WebServer
)
Add-LabMachineDefinition -Name DSCPull01 -Memory 4GB -Roles $roles -IpAddress 192.168.111.60 -OperatingSystem 'Windows Server 2022 Datacenter (Desktop Experience)'
Add-LabMachineDefinition -Name DSCPull01 -Memory 4GB -Roles $roles -IpAddress 192.168.111.60

# Build Server
Add-LabMachineDefinition -Name DSCDO01 -Memory 4GB -Roles AzDevOps -IpAddress 192.168.111.70
Add-LabMachineDefinition -Name DSCDO01 -Memory 6GB -Roles AzDevOps -IpAddress 192.168.111.70 -DiskName DSCDO01_D

#Hyper-V Host
# Hyper-V Host
$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 -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 All @@ -82,9 +85,8 @@ Install-Lab
Enable-LabCertificateAutoenrollment -Computer -User
Install-LabWindowsFeature -ComputerName (Get-LabVM -Role DSCPullServer, FileServer, WebServer, AzDevOps) -FeatureName RSAT-AD-Tools

# in case you screw something up
# In case you screw something up
Write-Host "1. - Creating Snapshot 'AfterInstall'" -ForegroundColor Magenta
Checkpoint-LabVM -All -SnapshotName AfterInstall
#endregion

Show-LabDeploymentSummary -Detailed
Show-LabDeploymentSummary -Detailed
32 changes: 17 additions & 15 deletions Lab/10 HyperV Full Lab with DSC and AzureDevOps.ps1
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
$labName = 'DscWorkshop'

#region Lab setup
#--------------------------------------------------------------------------------------------------------------------
#----------------------- CHANGING ANYTHING BEYOND THIS LINE SHOULD NOT BE REQUIRED ----------------------------------
#----------------------- + EXCEPT FOR THE LINES STARTING WITH: REMOVE THE COMMENT TO --------------------------------
#----------------------- + EXCEPT FOR THE LINES CONTAINING A PATH TO AN ISO OR APP --------------------------------
#--------------------------------------------------------------------------------------------------------------------

#create an empty lab template and define where the lab XML files and the VMs will be stored
# Create an empty lab template and define where the lab XML files and the VMs will be stored
New-LabDefinition -Name $labName -DefaultVirtualizationEngine HyperV

#make the network definition
# Make the network definition
Add-LabVirtualNetworkDefinition -Name $labName -AddressSpace 192.168.111.0/24
Add-LabVirtualNetworkDefinition -Name 'Default Switch' -HyperVProperties @{ SwitchType = 'External'; AdapterName = 'Wi-Fi' }

#and the domain definition with the domain admin account
# and the domain definition with the domain admin account
Add-LabDomainDefinition -Name contoso.com -AdminUser Install -AdminPassword Somepass1

#these credentials are used for connecting to the machines. As this is a lab we use clear-text passwords
# These credentials are used for connecting to the machines. As this is a lab we use clear-text passwords
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_2020.1.1_x64_dvd_b97c496e.iso #from https://docs.microsoft.com/en-us/azure/devops/server/download/azuredevopsserver?view=azure-devops
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 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.

#defining default parameter values, as these ones are the same for all the machines
# Data Disks
Add-LabDiskDefinition -Name DSCDO01_D -DiskSizeInGb 120 -Label DataDisk1 -DriveLetter D
Add-LabDiskDefinition -Name DSCHost01_D -DiskSizeInGb 120 -Label DataDisk1 -DriveLetter D

# Defining default parameter values, as these ones are the same for all the machines
$PSDefaultParameterValues = @{
'Add-LabMachineDefinition:Network' = $labName
'Add-LabMachineDefinition:ToolsPath' = "$labSources\Tools"
Expand All @@ -34,13 +37,13 @@ $PSDefaultParameterValues = @{
'Add-LabMachineDefinition:Gateway' = '192.168.111.50'
}

#The PostInstallationActivity is just creating some users
# The PostInstallationActivity is just creating some users
$postInstallActivity = @()
$postInstallActivity += Get-LabPostInstallationActivity -ScriptFileName 'New-ADLabAccounts 2.0.ps1' -DependencyFolder $labSources\PostInstallationActivities\PrepareFirstChildDomain
$postInstallActivity += Get-LabPostInstallationActivity -ScriptFileName PrepareRootDomain.ps1 -DependencyFolder $labSources\PostInstallationActivities\PrepareRootDomain
Add-LabMachineDefinition -Name DSCDC01 -Memory 1GB -Roles RootDC -IpAddress 192.168.111.10 -PostInstallationActivity $postInstallActivity

#file server and router
# File server and router
$netAdapter = @()
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch $labName -Ipv4Address 192.168.111.50
$netAdapter += New-LabNetworkAdapterDefinition -VirtualSwitch 'Default Switch' -UseDhcp
Expand All @@ -56,20 +59,20 @@ $roles = @(
SqlServer = 'DSCCASQL01'
DatabaseName = 'DSC'
}
Get-LabMachineRoleDefinition -Role TfsBuildWorker -Properties @{ NumberOfBuildWorkers = '4' }
# Get-LabMachineRoleDefinition -Role TfsBuildWorker -Properties @{ NumberOfBuildWorkers = '4' }
Get-LabMachineRoleDefinition -Role WebServer
)
Add-LabMachineDefinition -Name DSCPull01 -Memory 4GB -Roles $roles -IpAddress 192.168.111.60 -OperatingSystem 'Windows Server 2022 Datacenter (Desktop Experience)'
Add-LabMachineDefinition -Name DSCPull01 -Memory 4GB -Roles $roles -IpAddress 192.168.111.60

# Build Server
Add-LabMachineDefinition -Name DSCDO01 -Memory 4GB -Roles AzDevOps -IpAddress 192.168.111.70
Add-LabMachineDefinition -Name DSCDO01 -Memory 6GB -Roles AzDevOps -IpAddress 192.168.111.70 -DiskName DSCDO01_D

#Hyper-V Host
# Hyper-V Host
$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
Add-LabMachineDefinition -Name DSCHost01 -Memory 8GB -Roles $roles -IpAddress 192.168.111.80 -DiskName DSCHost01_D

# DSC target nodes - our legacy VMs with an existing configuration
Add-LabMachineDefinition -Name DSCFile01 -Memory 1GB -Roles FileServer -IpAddress 192.168.111.100
Expand All @@ -96,6 +99,5 @@ Invoke-LabCommand -ActivityName 'Disable Windows Update Service and DisableRealt
# in case you screw something up
Write-Host "1. - Creating Snapshot 'AfterInstall'" -ForegroundColor Magenta
Checkpoint-LabVM -All -SnapshotName AfterInstall
#endregion

Show-LabDeploymentSummary -Detailed
6 changes: 3 additions & 3 deletions Lab/20 Lab Customizations.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ $requiredChocolateyPackages = @{
}

$vsCodeDownloadUrl = 'https://go.microsoft.com/fwlink/?Linkid=852157'
$gitDownloadUrl = 'https://github.com/git-for-windows/git/releases/download/v2.34.1.windows.1/Git-2.34.1-64-bit.exe'
$vscodePowerShellExtensionDownloadUrl = 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/PowerShell/2021.10.2/vspackage'
$gitDownloadUrl = 'https://github.com/git-for-windows/git/releases/download/v2.40.0.windows.1/Git-2.40.0-64-bit.exe'
$vscodePowerShellExtensionDownloadUrl = 'https://marketplace.visualstudio.com/_apis/public/gallery/publishers/ms-vscode/vsextensions/PowerShell/2023.3.3/vspackage'
$chromeDownloadUrl = 'https://dl.google.com/tag/s/appguid%3D%7B8A69D345-D564-463C-AFF1-A69D9E530F96%7D%26iid%3D%7BC9D94BD4-6037-E88E-2D5A-F6B7D7F8F4CF%7D%26lang%3Den%26browser%3D5%26usagestats%3D0%26appname%3DGoogle%2520Chrome%26needsadmin%3Dprefers%26ap%3Dx64-stable-statsdef_1%26installdataindex%3Dempty/chrome/install/ChromeStandaloneSetup64.exe'
$notepadPlusPlusDownloadUrl = 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.1.9.3/npp.8.1.9.3.Installer.exe'
$notepadPlusPlusDownloadUrl = 'https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v8.5.1/npp.8.5.1.Installer.x64.exe'

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

Expand Down
27 changes: 14 additions & 13 deletions RequiredModules.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,41 @@
}
}

'powershell-yaml' = '0.4.3'
InvokeBuild = '5.9.12'
'powershell-yaml' = '0.4.7'
InvokeBuild = '5.10.3'
PSScriptAnalyzer = '1.21.0'
Pester = '5.3.3'
Plaster = '1.1.3'
Pester = '5.4.0'
Plaster = '1.1.4'
ModuleBuilder = '2.0.0'
ChangelogManagement = '2.1.4'
Sampler = '0.115.0'
ChangelogManagement = '3.0.1'
Sampler = '0.116.2'
'Sampler.GitHubTasks' = '0.3.5-preview0002'
'Sampler.AzureDevOpsTasks' = '0.1.2'
PowerShellForGitHub = '0.16.1'
'Sampler.DscPipeline' = '0.2.0-preview0003'
'Sampler.DscPipeline' = '0.2.0-preview0012'
MarkdownLinkCheck = '0.2.0'
'DscResource.AnalyzerRules' = '0.2.0'
DscBuildHelpers = '0.2.1'
Datum = '0.40.1-preview0001'
ProtectedData = '4.1.3'
'Datum.ProtectedData' = '0.0.1'
'Datum.InvokeCommand' = '0.3.0-preview0006'
ReverseDSC = '2.0.0.13'
'Datum.InvokeCommand' = '0.3.0'
ReverseDSC = '2.0.0.14'
Configuration = '1.5.1'
Metadata = '1.5.7'
xDscResourceDesigner = '1.13.0.0'
'DscResource.Test' = '0.16.1'
'DscResource.DocGenerator' = '0.11.1'
'DscResource.DocGenerator' = '0.11.2'

# Composites
'DscConfig.Demo' = '0.8.1-preview0002'
'DscConfig.Demo' = '0.8.3'

#DSC Resources
xPSDesiredStateConfiguration = '9.1.0'
ComputerManagementDsc = '8.5.0'
ComputerManagementDsc = '9.0.0'
NetworkingDsc = '9.0.0'
JeaDsc = '0.7.2'
xWebAdministration = '3.3.0'
WebAdministrationDsc = '4.1.0'
FileSystemDsc = '1.1.1'
SecurityPolicyDsc = '2.10.0.0'
xDscDiagnostics = '2.8.0'
Expand Down
5 changes: 5 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ BuildWorkflow:
- Compress_Artifact_Collections
- TestBuildAcceptance

rsop:
- Init
- LoadDatumConfigData
- CompileDatumRsop

####################################################
# PESTER Configuration #
####################################################
Expand Down
4 changes: 2 additions & 2 deletions source/Roles/WebServer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ WebApplicationPools:
Ensure: Present
IdentityType: ApplicationPoolIdentity
State: Started
DependsOn: '[xWebAppPool]TestAppPool1'
DependsOn: '[WebAppPool]TestAppPool1'
DependsOn:
- '[FilesAndFolders]FilesAndFolders'
- '[WindowsFeatures]WindowsFeatures'
Expand All @@ -47,7 +47,7 @@ WebApplications:
WebAppPool: TestAppPool2
Website: Default Web Site
Ensure: Present
DependsOn: '[xWebApplication]TestApp1'
DependsOn: '[WebApplication]webapp_TestApp1'
DependsOn: '[WebApplicationPools]WebApplicationPools'

RegistryValues:
Expand Down

0 comments on commit f24fbc3

Please sign in to comment.