gaelcolas / DscInfraSample

A Control Repo for a DSC Infrastructure as Code
MIT License
47 stars 22 forks source link

Unable to run initial build due to failing tests #25

Open tomer-ds opened 4 years ago

tomer-ds commented 4 years ago

Hi Gael,

I have found your articles about this approach and this repositroy to very much link up with the biggest issue I have with DSC. So thanks!!!

I am however seeing this issue when running the build.ps1 -ResolveDependencies. Apparently it is downloading pester 5 that comes with many breaking changes. :

WARNING: You are using Legacy parameter set that adapts Pester 5 syntax to Pester 4 syntax. This parameter set is
deprecated, and does not work 100%. The -Strict and -PesterOption parameters are ignored, and providing advanced
configuration to -Path (-Script), and -CodeCoverage via a hash table does not work. Please refer to
https://github.com/pester/Pester/releases/tag/5.0.1#legacy-parameter-set for more information.

Starting discovery in 1 files.
Discovery finished in 2.5s.
[-] Datum Tree Definition.Exists in DSC_ConfigData Folder 294ms (137ms|157ms)
 ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null.
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:14
[-] Node Definition Files.AllNodes is not Empty 78ms (74ms|4ms)
 Expected a value, but got $null or empty.
 at $content | Should -Not -BeNullOrEmpty, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
[-] Node Definition Files.SRV01 Should not be duplicated 150ms (111ms|39ms)
 Expected $false, but got $true.
 at $nodeNames -contains $_.BaseName | Should -Be $false, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
[-] Node Definition Files.SRV01 is not Empty 15ms (12ms|3ms)
 Expected a value, but got $null or empty.
 at $content | Should -Not -BeNullOrEmpty, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
[-] Node Definition Files.SRV02 Should not be duplicated 12ms (9ms|3ms)
 Expected $false, but got $true.
 at $nodeNames -contains $_.BaseName | Should -Be $false, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
[-] Node Definition Files.SRV02 is not Empty 16ms (12ms|4ms)
 Expected a value, but got $null or empty.
 at $content | Should -Not -BeNullOrEmpty, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
[-] Node Definition Files.PRODSRV01 Should not be duplicated 18ms (14ms|4ms)
 Expected $false, but got $true.
 at $nodeNames -contains $_.BaseName | Should -Be $false, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:31
[-] Node Definition Files.PRODSRV01 is not Empty 10ms (7ms|3ms)
 Expected a value, but got $null or empty.
 at $content | Should -Not -BeNullOrEmpty, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:38
WARNING:  No Datum store found for DSC Resource
[-] Role Composition.Nodes for environment DEV.SRV01 has a valid Configurations Setting (!$null) 269ms (266ms|2ms)
 Expected no exception to be thrown, but an exception "The lookup of path 'Configurations' for node '' returned a Null value, but Null is not specified as Default. This is not allowed." was thrown from C:\Git\DscInfraSample\BuildOutput\Modules\datum\0.0.38\ScriptsToProcess\Resolve-NodeProperty.ps1:106 char:9
     +         throw "The lookup of path '$PropertyPath' for node '$($node.N ...
     +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
 at {Lookup Configurations -Node $node -DatumTree $datum } | Should -Not -Throw, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
WARNING:  No Datum store found for DSC Resource
[-] Role Composition.Nodes for environment DEV.SRV02 has a valid Configurations Setting (!$null) 22ms (19ms|3ms)
 Expected no exception to be thrown, but an exception "The lookup of path 'Configurations' for node '' returned a Null value, but Null is not specified as Default. This is not allowed." was thrown from C:\Git\DscInfraSample\BuildOutput\Modules\datum\0.0.38\ScriptsToProcess\Resolve-NodeProperty.ps1:106 char:9
     +         throw "The lookup of path '$PropertyPath' for node '$($node.N ...
     +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
 at {Lookup Configurations -Node $node -DatumTree $datum } | Should -Not -Throw, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
WARNING:  No Datum store found for DSC Resource
[-] Role Composition.Nodes for environment PROD.SRV01 has a valid Configurations Setting (!$null) 20ms (18ms|2ms)
 Expected no exception to be thrown, but an exception "The lookup of path 'Configurations' for node '' returned a Null value, but Null is not specified as Default. This is not allowed." was thrown from C:\Git\DscInfraSample\BuildOutput\Modules\datum\0.0.38\ScriptsToProcess\Resolve-NodeProperty.ps1:106 char:9
     +         throw "The lookup of path '$PropertyPath' for node '$($node.N ...
     +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
 at {Lookup Configurations -Node $node -DatumTree $datum } | Should -Not -Throw, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
WARNING:  No Datum store found for DSC Resource
[-] Role Composition.Nodes for environment PROD.SRV02 has a valid Configurations Setting (!$null) 25ms (22ms|3ms)
 Expected no exception to be thrown, but an exception "The lookup of path 'Configurations' for node '' returned a Null value, but Null is not specified as Default. This is not allowed." was thrown from C:\Git\DscInfraSample\BuildOutput\Modules\datum\0.0.38\ScriptsToProcess\Resolve-NodeProperty.ps1:106 char:9
     +         throw "The lookup of path '$PropertyPath' for node '$($node.N ...
     +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.
 at {Lookup Configurations -Node $node -DatumTree $datum } | Should -Not -Throw, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
 at <ScriptBlock>, C:\Git\DscInfraSample\Tests\01 ConfigData\ConfigData.Tests.ps1:67
Tests completed in 5.83s
Tests Passed: 9, Failed: 12, Skipped: 0 NotRun: 0
ERROR: Assertion failed.
At C:\Git\DscInfraSample\.Build.ps1:272 char:5
+     assert ($testResults.FailedCount -eq 0)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\Git\DscInfraSample\.Build.ps1:259 char:1
+ task Test_ConfigData {
+ ~~~~~~~~~~~~~~~~~~~~~~
At C:\Git\DscInfraSample\.Build.ps1:204 char:5
+     task . Clean_BuildOutput,
+     ~~~~~~~~~~~~~~~~~~~~~~~~~
WARNING:        No Datum store found for DSC Resource Task: Test_ConfigData. File: C:\Git\DscInfraSample\.Build.ps1.
WARNING:        No Datum store found for DSC Resource Task: Test_ConfigData. File: C:\Git\DscInfraSample\.Build.ps1.
WARNING:        No Datum store found for DSC Resource Task: Test_ConfigData. File: C:\Git\DscInfraSample\.Build.ps1.
WARNING:        No Datum store found for DSC Resource Task: Test_ConfigData. File: C:\Git\DscInfraSample\.Build.ps1.
Build FAILED. 7 tasks, 1 errors, 4 warnings 00:00:25.6782806
assert : Assertion failed.
At C:\Git\DscInfraSample\.Build.ps1:272 char:5
+     assert ($testResults.FailedCount -eq 0)
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Assert-Build], Exception
    + FullyQualifiedErrorId : Assert-Build

I also see the following when attempting to run help:

PS C:\Git\DscInfraSample> .\.Build.ps1 -Help

Name                            Jobs                                                                                      Synopsis
----                            ----                                                                                      --------
Clean_BuildOutput               {}
Clean_Module                    {}
PSModulePath_BuildModules       {Download_All_Dependencies, {}}
Load_Datum_ConfigData           {}
Compile_Root_Configuration      {}
Compile_Root_Meta_Mof           {}
Create_Mof_Checksums            {}
Compile_Datum_Rsop              {}
.                               {Clean_BuildOutput, PSModulePath_BuildModules, Test_ConfigData, Load_Datum_ConfigData...}
Download_All_Dependencies       {Download_DSC_Configurations, Download_DSC_Resources}
Download_DSC_Resources          {}
Download_DSC_Configurations     {}
Clean_DSC_Resources_Folder      {}
Clean_DSC_Configurations_Folder {}
Zip_Modules_For_Pull_Server     {}
Test_ConfigData                 {}
Set-BuildHeader : The term 'Set-BuildHeader' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included,       
verify that the path is correct and try again.
At C:\Git\DscInfraSample\.Build.ps1:189 char:5
+     Set-BuildHeader $TaskHeader
+     ~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-BuildHeader:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

task : The term 'task' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is     
correct and try again.
At C:\Git\DscInfraSample\.Build.ps1:204 char:5
+     task . Clean_BuildOutput,
+     ~~~~
    + CategoryInfo          : ObjectNotFound: (task:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

task : The term 'task' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is 
correct and try again.
At C:\Git\DscInfraSample\.Build.ps1:217 char:1
+ task Download_All_Dependencies -if ($DownloadResourcesAndConfiguratio ...
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (task:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

task : The term 'task' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is     
correct and try again.
At C:\Git\DscInfraSample\.Build.ps1:224 char:1
+ task Download_DSC_Resources .....

Am I missing something?

gaelcolas commented 4 years ago

Yeah, to work you ought to pin version 4.10.1 in the PSDepend psd1 file... But generally, I recommend starting with the dsccommunity/DscWorkshop project instead. It's an evolution from this sample project.

gaelcolas commented 4 years ago

Hey, I'm not on a plane anymore, so I can give you a bit more details on this: https://github.com/gaelcolas/DscInfraSample/blob/master/PSDepend.build.psd1#L17 On this line you can see that the dependency it pulling the latest version of Pester at build time. As you saw, Pester 5 has breaking changes from Pester 4, and that's expected as per the major version increment.

So to fix that locally, you should replace latest by 4.10.1, remove the v5 downloaded to your ./BuildOutput/Modules/Pester folder. And from a clean session redo a .build.ps1 -resolveDependency.

That should get you unstuck, but IMO you should probably look into DscWorkshop here:

The DSC Workshop is very similar approach to DscInfraSample, reworked and extended by @raandree @nyanhp, and I've contributed with my opinion here and there...

The work they've done is amazing and the best way I know to get started with a custom DSC (whether using Azure Automation DSC where you compile the MOFs yourselves, or using the Windows 2019 Pull server, or using a third party like AWS System Manager).

The "dependency" on AutomatedLab is mainly for automating the lab part (spinning up vms and bootstrapping them), but then relies on the DSC Pipeline for configuration (that's the part you're probably most interested in from a production point of view).

I'll update my blog posts and this repo to redirect to DSC Workshop, thanks for the reminder ;)