Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SynEdgy/Sampler.DscPipeline into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelcolas committed Feb 8, 2023
2 parents e531994 + da5155e commit 1f3b6e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added error handling discovering 'CompileRootConfiguration.ps1' and 'RootMetaMof.ps1'
- Test cases updated to Pester 5.
- Fixing issue with ZipFile class not being present
- Increase build speed of root configuration by only importing required Composites/Resources
- Added ''UseEnvironment'' parameter to cater for RSOP for identical node names in different environments
- Adding Home.md to wikiSource and correct casing.

Expand Down
29 changes: 21 additions & 8 deletions source/Scripts/CompileRootConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,32 +39,45 @@ if ($BuildInfo.'Sampler.DscPipeline'.DscCompositeResourceModules.Count -lt 1)
}

Write-Host -Object "RootConfiguration will import these composite resource modules as defined in 'build.yaml':"
$importStatements = foreach ($module in $BuildInfo.'Sampler.DscPipeline'.DscCompositeResourceModules)
foreach ($module in $BuildInfo.'Sampler.DscPipeline'.DscCompositeResourceModules)
{
if ($module -is [hashtable])
{
Write-Host -Object "`t- $($module.Name) ($($module.Version))"
"Import-DscResource -ModuleName $($module.Name) -ModuleVersion $($module.Version)`n"
}
else
{
Write-Host -Object "`t- $module"
"Import-DscResource -ModuleName $module`n"
}
}

Write-Host -Object ''

$rootConfiguration = Get-Content -Path $PSScriptRoot\RootConfiguration.ps1 -Raw
$rootConfiguration = $rootConfiguration -replace '#<importStatements>', $importStatements
Write-Host -Object "Preloading available resources"
$availableResources = Get-DscResource

Invoke-Expression -Command $rootConfiguration
Write-Host -Object ''

$configData = @{}
$configData.Datum = $ConfigurationData.Datum

foreach ($node in $rsopCache.GetEnumerator())
{
$importStatements = foreach ($configurationItem in $node.Value.Configurations)
{
$resource = $availableResources.Where({$_.Name -eq $configurationItem})
if ($null -eq $resource)
{
Write-Debug -Message "No DSC resource found for configuration $configurationItem"
continue
}

"Import-DscResource -ModuleName $($resource.ModuleName) -ModuleVersion $($resource.Version) -Name $($resource.Name)`n"
}

$rootConfiguration = Get-Content -Path $PSScriptRoot\RootConfiguration.ps1 -Raw
$rootConfiguration = $rootConfiguration -replace '#<importStatements>', ($importStatements | Select-Object -Unique)

Invoke-Expression -Command $rootConfiguration

$configData.AllNodes = @([hashtable]$node.Value)
try
{
Expand Down
2 changes: 1 addition & 1 deletion source/WikiSource/Home.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ Welcome to the documentation wiki for the Sampler DSC Pipeline

# Usage

The `Sampler.DscPipeline` PowerShell module is an extension to [Sampler](github.com/synedgy/Sampler),
The `Sampler.DscPipeline` PowerShell module is an extension to [Sampler](https://github.com/gaelcolas/Sampler),
providing tasks to implement a DSC pipeline to create DSC artefacts as used in the
[DSC Workshop](https://github.com/dsccommunity/DscWorkshop).

0 comments on commit 1f3b6e0

Please sign in to comment.