gaelcolas / dscinfrasample Goto Github PK
View Code? Open in Web Editor NEWA Control Repo for a DSC Infrastructure as Code
License: MIT License
A Control Repo for a DSC Infrastructure as Code
License: MIT License
Looking at Ryan's presentation, I realise I forgot to support signature validation on the meta MOFs
Thanks for putting this together. I am in a journey of learning more about DSC and in the process of learning how to scaffold for potentially thousands of endpoints where managing exceptions is a critical aspect of implementation considerations.
I am struggling to see in your example implementation how I can go about potentially having a main DSC configuration to manage local accounts across all endpoints while also having the flexibility of adding/removing accounts for endpoints that require special handling?
I know I made the question around managing local accounts very specific, this is more of a question around exception handling than a solution around managing local accounts. In case it's not obvious in my line of questioning.
Currently those aren't added to path when you run a .build.ps1, so it errors if the modules are already present.
PS C:\Temp\DscInfraSample-DEV> .\.Build.ps1
Invoke-Build : The term 'Invoke-Build' 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:\Temp\Git\DscInfraSample-DEV\.Build.ps1:39 char:9
+ Invoke-Build $Tasks $MyInvocation.MyCommand.Path @PSBoundPara ...
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Build:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
I don't see an Invoke-Build
function anywhere that you've provided. Does this repo function by itself or are there dependencies that I'm not noticing? I can only assume you're needing https://github.com/nightroman/Invoke-Build as a dependency.
Even with InvokeBuild
installed (Install-Module InvokeBuild -Force
), I still have errors:
PS C:\Temp\Git\DscInfraSample> .\.Build.ps1
DSC_Configurations
Build . C:\Temp\Git\DscInfraSample\.Build.ps1
Task /./Clean
------------------------------------------------------------------------------
CLEAN UP
------------------------------------------------------------------------------
Done /./Clean 00:00:00.0365730
Task /./PSModulePath_BuildModules
Done /./PSModulePath_BuildModules 00:00:00.0160784
Task /./test
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0.30 datum {Get-DatumRSOP, Get-FileProviderData, Get-MergeStrategyFromPath, Invoke-ProtectedDatumAction...}
Script 3.4.0 Pester {Describe, Context, It, Should...}
Done /./test 00:00:00.1213200
Task /./LoadResource
ERROR: The term 'Invoke-PSDepend' 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:\Temp\Git\DscInfraSample\.Build.ps1:60 char:13
+ Invoke-PSDepend -Path $PSDependResourceDefinition -Confir ...
+ ~~~~~~~~~~~~~~~
At C:\Temp\Git\DscInfraSample\.Build.ps1:57 char:5
+ task LoadResource {
+ ~~~~~~~~~~~~~~~~~~~
At C:\Temp\Git\DscInfraSample\.Build.ps1:52 char:5
+ task . Clean,PSModulePath_BuildModules,test,LoadResource,LoadConf ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 5 tasks, 1 errors, 0 warnings 00:00:00.7169683
Invoke-PSDepend : The term 'Invoke-PSDepend' 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:\Temp\Git\DscInfraSample\.Build.ps1:60 char:13
+ Invoke-PSDepend -Path $PSDependResourceDefinition -Confir ...
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-PSDepend:String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException
The SRV02 in DEV defines
Shared1:
DestinationPath: C:\MyRoleParam.txt
Param1: This is the Node override!
However the MOF files and also RSOP still have the value as defined in WindowsBase.yml
Shared1:
DestinationPath: C:\MyRoleParam.txt
Param1: This is the Role Value!
Are the lookup options for the value incorrect? I have tried 'hash' and 'deep', both did not work.
.Build.ps1 -ResolveDependency
runs fine, until COMPILE ROOT CONFIGURATION
SRV01 : SRV01 : MOF__70b45ea Dev
PSDesiredStateConfiguration\node : In C:\Users\paul\Documents\git\DscInfraSample\DSC_Resources\xPSDesiredStateConfigura
tion\8.2.0.0\DSCPullServerSetup\PublishModulesAndMofsToPullServer.psm1:43 Zeichen:16
Log -Scope $MyInvocation -Message 'Start Deployment'
~~~~~~~~~~~~~
and many more erros all related to xPSDesiredStateConfiguration
SRV02 : SRV02 : MOF__70b45ea Dev
SRV02 : WindowsBase ::> Shared1 ....................................................................................OK
SRV02 : WindowsBase ::> SoftwareBase ...............................................................................OK
ERROR OCCURED DURING COMPILATION
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:3917
Zeichen:5
throw $ErrorRecord
~~~~~~~~~~~~~~~~~~
and another error about Get-DscSplattedResource could not be loaded.
ROOT META MOF compiles woithout any error.
I think it is because of
PowerShell/PowerShell#7209
Staying at Windows Powershell, what should I do to overcome it right now?
===============================================================================
COMPILE ROOT CONFIGURATION
/./Compile_Root_Configuration
C:\DEV\DscInfraSample.build\DSC\ConfigData.Build.ps1:91
PSDesiredStateConfiguration\Configuration : The term 'Set-PSTopConfigurationName' 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:\DEV\DscInfraSample\RootConfiguration.ps1:7 char:1
+ CategoryInfo : ObjectNotFound: (Set-PSTopConfigurationName:String) [Configuration], ParentContainsError
RecordException
+ FullyQualifiedErrorId : CommandNotFoundException,Configuration
ERROR OCCURED DURING COMPILATION: Compilation errors occurred while processing configuration 'RootConfiguration'. Please review the errors reported in error stream and modify your configuration code appropriately.
Compilation errors occurred while processing configuration 'RootConfiguration'. Please review the errors reported in
error stream and modify your configuration code appropriately.
At
C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:3917
char:5
throw $ErrorRecord
~~~~~~~~~~~~~~~~~~
PSDesiredStateConfiguration\Configuration : The term 'Set-PSTopConfigurationName' 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:\DEV\DscInfraSample\RootConfiguration.ps1:7 char:1
+ CategoryInfo : ObjectNotFound: (Set-PSTopConfigurationName:String) [Configuration], ParentContainsError
RecordException
+ FullyQualifiedErrorId : CommandNotFoundException,Configuration
Exception calling "InvokeWithContext" with "2" argument(s): "The term 'Set-PSTopConfigurationName' 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:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration\PSDesiredStateConfiguration.psm1:2232
char:13
$result = $Body.InvokeWithContext($functionsToDefine, $va ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DscInfraSample/RootConfiguration.ps1
Line 22 in 9df38c6
@gaelcolas can I check my understanding of how this works please?
If using Datum, there is a use case where configurations get merged for a node. In such a case, there might be multiple instances of a confiiguration for example where all nodes have an agent that runs as a service, then the role of the node added a service for the application.
In the line, I've referenced above, Get-DSCSplattedResource, would use the Configruation name "Service" as the resourceID when the MOF is created. In such cases, where there are multiple instanced the MOF would fail to compile since you may only have a since resourceID of "Service" Is my understanding here correct?
If my understanding here is correct, is the correct way to handle such situations to include another key in the properties described within the Datum tree, for example matching the "Title" and "Name" concept of Puppet?
Originally created by @Outek in Datum as gaelcolas/datum#52. As this is not a Datum but more DSC issue, I am duplicating the issue here. See for details.
I've noticed an error after the CU June for my 2016 Server, and i took me some time to find out, what possibly cause this error.
After the (update)reboot i was not longer able to build the mof files. The error message was this one:
===============================================================================
COMPILE ROOT CONFIGURATION
-------------------------------------------------------------------------------
/./Compile_Root_Configuration
C:\Temp\DSC\.build\DSC\ConfigData.build.ps1:63
-----------------------
FilteredNode:
-----------------------
PSDesiredStateConfiguration\Configuration : The term 'Set-PSTopConfigurationName' 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:\Temp\DSC\RootConfiguration.ps1:7 char:1
+ configuration "RootConfiguration"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-PSTopConfigurationName:String) [Configuration], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : CommandNotFoundException,Configuration
ERROR OCCURED DURING COMPILATION
Done /./Compile_Root_Configuration 00:00:15.2377078
As mentioned before, this happened only on a fresh patched buildserver.
PS C:\Temp\DSC> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.2312
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.2312
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I copied the Module PSDesiredStateConfiguration from an unpatched prod server to this server with the error to "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\PSDesiredStateConfiguration" and replaced this module. The feshly started build of the mof files went through as usual.
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.