From c6aef462fe94e300d4ca566c8389330e828569ad Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Sat, 14 Oct 2017 22:14:36 +0100 Subject: [PATCH 1/7] renaming in line with DscInfraSample --- .gitignore | 1 + {RequiredResources => DSC_Resources}/README.md | 0 PSDepend.resources.psd1 | 2 +- 3 files changed, 2 insertions(+), 1 deletion(-) rename {RequiredResources => DSC_Resources}/README.md (100%) diff --git a/.gitignore b/.gitignore index 77265a9..b9c1739 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,6 @@ modules/* .kitchen/* Resources/* RequiredResources/* +DSC_Resources/* !**/README.md \ No newline at end of file diff --git a/RequiredResources/README.md b/DSC_Resources/README.md similarity index 100% rename from RequiredResources/README.md rename to DSC_Resources/README.md diff --git a/PSDepend.resources.psd1 b/PSDepend.resources.psd1 index ebd5259..ac83422 100644 --- a/PSDepend.resources.psd1 +++ b/PSDepend.resources.psd1 @@ -1,7 +1,7 @@ @{ PSDependOptions = @{ AddToPath = $True - Target = 'RequiredResources' + Target = 'DSC_Resources' Parameters = @{ #Force = $True #Import = $True From d5d5c13829aaccacd4e10fc2ea9fbd5ee1ce2797 Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Tue, 21 Nov 2017 17:22:32 +0000 Subject: [PATCH 2/7] adding dsc resource for demo --- README.md | 55 ++++++++++--------- .../DscResources/Shared1/Shared1.schema.psm1 | 4 -- .../SoftwareBase/SoftwareBase.psd1 | 29 ++++++++++ .../SoftwareBase/SoftwareBase.schema.psm1 | 37 +++++++++++++ 4 files changed, 96 insertions(+), 29 deletions(-) create mode 100644 SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 create mode 100644 SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 diff --git a/README.md b/README.md index c1e8ffb..19f7dea 100644 --- a/README.md +++ b/README.md @@ -52,50 +52,55 @@ Below are ideas I think worth discussing and suggestions of implementation. Plea ### Repository Structure ``` -C:\SRC\SHAREDDSCCONFIG +SHAREDDSCCONFIG │ .build.ps1 │ .gitignore │ .kitchen.yml │ appveyor.yml -│ Dependencies.psd1 │ LICENSE +│ PSDepend.build.psd1 +│ PSDepend.resources.psd1 │ README.md │ ├───.build │ README.md -├───.kitchen -│ ├───logs -│ ├───OtherTestSuite-2012r2-WMF5 -│ │ └───OtherTestSuite-2012r2-WMF5 -│ │ ├───Snapshots -│ │ └───Virtual Machines -│ └───SharedDscConfig-2012r2-WMF5 -│ └───SharedDscConfig-2012r2-WMF5 -│ ├───Snapshots -│ └───Virtual Machines +│ +├───BuildOutput +│ README.md +│ ├───docs -├───DscBuildOutput -│ └───modules [pulled according to Dependencies.psd1, modules not in git] -│ ├───BuildHelpers -│ ├───Datum -│ ├───DscBuildHelpers -│ ├───InvokeBuild -│ ├───Pester -│ ├───platyPS -│ ├───PSDeploy -│ └───PSScriptAnalyzer +│ └───media +│ +├───DSC_Resources +│ README.md +│ └───SharedDscConfig + │ SharedDscConfig.psd1 + │ ├───DscResources │ └───Shared1 + │ │ Shared1.psd1 + │ │ Shared1.schema.psm1 + │ │ │ ├───ConfigData + │ │ │ Datum.yml + │ │ │ │ │ └───common + │ │ SharedDscConfig.psd1 + │ │ │ └───Diagnostics │ ├───Comprehensive │ └───Simple + │ SharedDscConfig.tests.ps1 + │ └───examples - ├───ConfigData - │ └───AllNodes - └───DscBuildOutput + │ Default.ps1 + │ + └───ConfigData + │ Datum.yml + │ + └───AllNodes + localhost.yml ``` The Shared Configuration should be self contained, but will require files for building/testing or development. The repository will hence need some project files on top of the files required for functionality. diff --git a/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 b/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 index 3766174..bad1ff1 100644 --- a/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 +++ b/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 @@ -5,7 +5,6 @@ Configuration Shared1 { ) Import-DscResource -ModuleName PSDesiredStateConfiguration - Import-DscResource -ModuleName Chocolatey File TestFile { Ensure = 'Present' @@ -13,7 +12,4 @@ Configuration Shared1 { Contents = $Param1 } - ChocolateySoftware InstallChoco { - Ensure = 'Present' - } } \ No newline at end of file diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 new file mode 100644 index 0000000..4737ba9 --- /dev/null +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 @@ -0,0 +1,29 @@ +@{ + + # Script module or binary module file associated with this manifest. + RootModule = 'SoftwareBase.schema.psm1' + + # Version number of this module. + ModuleVersion = '0.0.1' + + # ID used to uniquely identify this module + GUID = '78db8da3-b47e-4272-a24c-037842ff6164' + + # Author of this module + Author = 'Gael Colas' + + # Company or vendor of this module + CompanyName = 'SynEdgy Ltd' + + # Copyright statement for this module + Copyright = '(c) 2017 Gael. All rights reserved.' + + # Modules that must be imported into the global environment prior to importing this module + RequiredModules = @('PSDesiredStateConfiguration') + + # DSC resources to export from this module + DscResourcesToExport = @('SoftwareBase') + + } + + \ No newline at end of file diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 new file mode 100644 index 0000000..fbf1b30 --- /dev/null +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 @@ -0,0 +1,37 @@ +Configuration SoftwareBase { + Param( + $PackageFeedUrl = 'https://chocolatey.org/api/v2', + $Sources = @(), + $Packages, + $ChocolateyLicenseXml + ) + + Import-DscResource -ModuleName PSDesiredStateConfiguration + Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.31 + + ChocolateySoftware ChocoInstall { + Ensure = 'Present' + PackageFeedUrl = $PackageFeedUrl + } + + foreach($source in $Sources) { + if(!$source.Ensure) { $source.add('Ensure', 'Present') } + Get-DscSplattedResource -ResourceName ChocolateySource -ExecutionName "$($Source.Name)_src" -Properties $source + } + + if ($ChocolateyLicenseXml) { + File ChocolateyLicense { + Ensure = 'Present' + Contents = $ChocolateyLicenseXml + DestinationPath = 'C:\ProgramData\chocolatey\license\chocolatey.license.xml' + Type = 'File' + Force = $true + } + } + + foreach ($Package in $Packages) { + if(!$Package.Ensure) { $Package.add('Ensure','Present') } + if(!$Package.Version) { $Package.add('version', 'latest') } + Get-DscSplattedResource -ResourceName ChocolateyPackage -ExecutionName "$($Package.Name)_pkg" -Properties $Properties + } +} \ No newline at end of file From 788e542d8b09e7e7cafdcdd7e9f4880919da375b Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Tue, 21 Nov 2017 17:29:51 +0000 Subject: [PATCH 3/7] upping module version for testing --- SharedDscConfig/SharedDscConfig.psd1 | Bin 7840 -> 7840 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/SharedDscConfig/SharedDscConfig.psd1 b/SharedDscConfig/SharedDscConfig.psd1 index 87f03b07ea0baa74364abd893f3fd399d12e2622..2524c6eeaae551657a3919c4bbd0f826c32da346 100644 GIT binary patch delta 14 VcmZ2ryTEpX028C}W Date: Tue, 9 Jan 2018 21:15:11 +0000 Subject: [PATCH 4/7] updating version of chocolatey Module --- .../DscResources/SoftwareBase/SoftwareBase.schema.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 index fbf1b30..f345265 100644 --- a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 @@ -7,7 +7,7 @@ Configuration SoftwareBase { ) Import-DscResource -ModuleName PSDesiredStateConfiguration - Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.31 + Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.46 ChocolateySoftware ChocoInstall { Ensure = 'Present' From f9f461ec574452e432277142b7c6a1ab781de2ad Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Tue, 30 Jan 2018 17:39:00 +0000 Subject: [PATCH 5/7] Adding a framework that could leverage Test-Kitchen and Suites --- .build.ps1 | 15 +++++ PSDepend.build.psd1 | 2 +- PSDepend.resources.psd1 | 2 +- .../{common => default}/SharedDscConfig.psd1 | 0 .../DscResources/Shared1/Shared1.schema.psm1 | 2 +- .../SoftwareBase/SoftwareBase.psd1 | 2 +- .../SoftwareBase/SoftwareBase.schema.psm1 | 42 ++++++++++-- SharedDscConfig/SharedDscConfig.psd1 | Bin 7840 -> 7840 bytes SharedDscConfig/examples/ConfigData/Datum.yml | 8 +-- .../OtherTestSuite.yml} | 8 ++- .../ConfigData/TestSuites/SharedDscConfig.yml | 31 +++++++++ SharedDscConfig/examples/Default.ps1 | 63 +++++++++--------- SharedDscConfig/examples/init.ps1 | 9 +++ 13 files changed, 137 insertions(+), 47 deletions(-) rename SharedDscConfig/DscResources/Shared1/ConfigData/{common => default}/SharedDscConfig.psd1 (100%) rename SharedDscConfig/examples/ConfigData/{AllNodes/localhost.yml => TestSuites/OtherTestSuite.yml} (61%) create mode 100644 SharedDscConfig/examples/ConfigData/TestSuites/SharedDscConfig.yml create mode 100644 SharedDscConfig/examples/init.ps1 diff --git a/.build.ps1 b/.build.ps1 index 47f6142..002b09c 100644 --- a/.build.ps1 +++ b/.build.ps1 @@ -45,6 +45,12 @@ Process { Get-ChildItem -Path "$PSScriptRoot\$BuildOutput\" -Recurse | Remove-Item -force -Recurse -Exclude README.md } + task Noop { } + + task dsc { + . $PSScriptRoot\SharedDscConfig\examples\init.ps1 + } + task LoadResource { $PSDependResourceDefinition = '.\PSDepend.resources.psd1' if(Test-Path $PSDependResourceDefinition) { @@ -63,6 +69,15 @@ Process { begin { + + if (![io.path]::IsPathRooted($BuildOutput)) { + $BuildOutput = Join-Path -Path $PSScriptRoot -ChildPath $BuildOutput + } + + if(($Env:PSModulePath -split ';') -notcontains (Join-Path $BuildOutput 'modules') ) { + $Env:PSModulePath = (Join-Path $BuildOutput 'modules') + ';' + $Env:PSModulePath + } + function Resolve-Dependency { [CmdletBinding()] param() diff --git a/PSDepend.build.psd1 b/PSDepend.build.psd1 index 0eaa3c0..651de46 100644 --- a/PSDepend.build.psd1 +++ b/PSDepend.build.psd1 @@ -20,5 +20,5 @@ PlatyPS = 'latest' psdeploy = 'latest' 'gaelcolas/DscBuildHelpers' = 'master' - 'gaelcolas/Datum' = 'master' + Datum = 'latest' } \ No newline at end of file diff --git a/PSDepend.resources.psd1 b/PSDepend.resources.psd1 index ac83422..bc6fca6 100644 --- a/PSDepend.resources.psd1 +++ b/PSDepend.resources.psd1 @@ -8,5 +8,5 @@ } } - 'gaelcolas/Chocolatey' = 'master' + Chocolatey = '0.0.46' } \ No newline at end of file diff --git a/SharedDscConfig/DscResources/Shared1/ConfigData/common/SharedDscConfig.psd1 b/SharedDscConfig/DscResources/Shared1/ConfigData/default/SharedDscConfig.psd1 similarity index 100% rename from SharedDscConfig/DscResources/Shared1/ConfigData/common/SharedDscConfig.psd1 rename to SharedDscConfig/DscResources/Shared1/ConfigData/default/SharedDscConfig.psd1 diff --git a/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 b/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 index bad1ff1..b5ac21c 100644 --- a/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 +++ b/SharedDscConfig/DscResources/Shared1/Shared1.schema.psm1 @@ -6,7 +6,7 @@ Configuration Shared1 { Import-DscResource -ModuleName PSDesiredStateConfiguration - File TestFile { + File "TestFile_$(1..999|Get-Random)" { Ensure = 'Present' DestinationPath = $DestinationPath Contents = $Param1 diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 index 4737ba9..d542af8 100644 --- a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.psd1 @@ -4,7 +4,7 @@ RootModule = 'SoftwareBase.schema.psm1' # Version number of this module. - ModuleVersion = '0.0.1' + ModuleVersion = '0.0.2' # ID used to uniquely identify this module GUID = '78db8da3-b47e-4272-a24c-037842ff6164' diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 index f345265..14ca897 100644 --- a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 @@ -2,21 +2,25 @@ Configuration SoftwareBase { Param( $PackageFeedUrl = 'https://chocolatey.org/api/v2', $Sources = @(), - $Packages, - $ChocolateyLicenseXml + $ChocolateyLicenseXml, + $Settings = @(), + $Features = @(), + $Packages = @() ) Import-DscResource -ModuleName PSDesiredStateConfiguration Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.46 + # Install Choco Software if not present ChocolateySoftware ChocoInstall { Ensure = 'Present' PackageFeedUrl = $PackageFeedUrl } + # Configure Choco Sources to pull packages from foreach($source in $Sources) { if(!$source.Ensure) { $source.add('Ensure', 'Present') } - Get-DscSplattedResource -ResourceName ChocolateySource -ExecutionName "$($Source.Name)_src" -Properties $source + (Get-DscSplattedResource -ResourceName 'ChocolateySource' -ExecutionName "$($Source.Name)_src" -Properties $source -NoInvoke).Invoke($Source) } if ($ChocolateyLicenseXml) { @@ -27,11 +31,41 @@ Configuration SoftwareBase { Type = 'File' Force = $true } + + # If Choco is licensed, install Choco extension to enable Business Features + if($ChocoExtension = $Packages.Where{$_.Name -eq 'chocolatey.extension'}[0]) { + if(!$ChocoExtension.Ensure) {$ChocoExtension.Add('Ensure','present')} + if(!$ChocoExtension.Version) {$ChocoExtension.Add('Version','latest')} + (x ChocolateyPackage 'ChocoExtension' $ChocoExtension -NoInvoke).Invoke($ChocoExtension) + # Remove the Chocolatey Extension from the $Packages list if present + $Packages = $Packages.Where{$_.Name -ne 'chocolatey.extension'} + } + else { + # Install Default Extension if LIcensed and not specified + ChocolateyPackage ChocoExtension { + Ensure = 'Present' + Version = 'latest' + Name = 'Chocolatey.Extension' + DependsOn = '[File]ChocolateyLicense' + } + } + } + + # Configure Choco Settings + foreach ($Setting in $Settings) { + if(!$Setting.Ensure) {$Setting.Add('Ensure','Present')} + (x ChocolateySetting "$($Setting.Name)_set" $Setting -NoInvoke).Invoke($Setting) + } + + # Configure Choco Features + foreach ($Feature in $Features) { + if(!$Feature.Ensure) {$Feature.Add('Ensure','Present')} + (x ChocolateyFeature "$($Feature.Name)_Ftr" $Feature -NoInvoke).Invoke($Feature) } foreach ($Package in $Packages) { if(!$Package.Ensure) { $Package.add('Ensure','Present') } if(!$Package.Version) { $Package.add('version', 'latest') } - Get-DscSplattedResource -ResourceName ChocolateyPackage -ExecutionName "$($Package.Name)_pkg" -Properties $Properties + (Get-DscSplattedResource -ResourceName ChocolateyPackage -ExecutionName "$($Package.Name)_pkg" -Properties $Package -NoInvoke).Invoke($Package) } } \ No newline at end of file diff --git a/SharedDscConfig/SharedDscConfig.psd1 b/SharedDscConfig/SharedDscConfig.psd1 index 2524c6eeaae551657a3919c4bbd0f826c32da346..5aa0eeb1001517875d2fc840d579de5908bfd896 100644 GIT binary patch delta 14 VcmZ2ryTEpX028ChW>> $ProjectPath" - $Env:PSModulePath = $Env:PSModulePath +';'+ $ProjectPath.FullName -} -# load the Configuration Property resolver +$DatumConfig = Join-Path $PSScriptRoot "ConfigData\Datum.yml" +Write-Warning "Loading $DatumConfig" + +$Global:Datum = New-DatumStructure -definitionFile $DatumConfig -Import-Module -force Datum -Global -#. $here\scripts\Resolve-DscConfigurationData.ps1 -$yml = Get-Content -raw $Here\ConfigData\Datum.yml | ConvertFrom-Yaml +$AllNodes = @($Datum.TestSuites.psobject.Properties | ForEach-Object { + $Node = $Datum.TestSuites.($_.Name) + if(!$Node.contains('Name') ) { + $null = $Node.Add('Name',$_.Name) + } + (@{} + $Node) #Remove order & Case Sensitivity +}) -Push-Location $Here -$Global:Datum = New-DatumStructure $yml $Global:ConfigurationData = @{ - AllNodes = @($Datum.AllNodes.psobject.properties|%{ $Datum.AllNodes.($_.Name)}) + AllNodes = $AllNodes Datum = $Global:Datum } -#Load configuration Data -#$ConfigurationData = Import-PowerShellDataFile $here\..\ConfigurationData\Default\Default.psd1 -#$Node = $ConfigurationData.AllNodes.Where{$_.Nodename -eq 'localhost'}[0] -ipmo -force $here\..\SharedDscConfig.psd1 +#ipmo -force $here\..\SharedDscConfig.psd1 Configuration Default { @@ -30,24 +29,28 @@ Configuration Default { Node $ConfigurationData.AllNodes.NodeName { - Shared1 SharedConfig_NoParam { - # When no param specified, the default params will be used - } + # When no param specified, the default params will be used + Shared1 SharedConfig_NoParam {} + #Specifying a parameter the traditional way Shared1 SharedConfig_Param1 { - Param1 = 'This is the content from the Root configuration' - DestinationPath = 'C:\Test2.txt' #Using the same file as previous block would fail (2 Resource with same key for same Node) + Param1 = 'This is the content from the Root configuration. Traditional approach' + DestinationPath = 'C:\Test_2.txt' #Using the same file as previous block would fail (2 Resource with same key for same Node) } - Write-Warning ($Node|out-String) - Write-Warning (Lookup $Node 'Shared1'|out-String) + + #Write-Warning ($Node|out-String) + $(Write-Warning "Shared1 Parameters: $(Lookup 'Shared1'|Convertto-Json)") #Auto lookup Parameters for $node with Configuration - $Properties = $(Lookup $Node 'Shared1' -DefaultValue @{}) - Get-DscSplattedResource -ResourceName 'Shared1' -ExecutionName 'Shared1' -Properties $Properties - - #or in short notation - #x 'Shared1' 'Shared1' $Properties - + $Properties = $(Lookup 'Shared1') + (Get-DscSplattedResource -ResourceName 'Shared1' -ExecutionName 'Shared1_FromNodeBlock' -Properties $Properties -NoInvoke).Invoke($Properties) + + #Auto lookup configurations for that node, and foreach of them, look for its params and splat them + (Lookup Configurations).Foreach{ + $ConfigName = $_ + $Properties = Lookup $ConfigName -DefaultValue @{} + (x $ConfigName $ConfigName $Properties -NoInvoke).Invoke($Properties) + } } } diff --git a/SharedDscConfig/examples/init.ps1 b/SharedDscConfig/examples/init.ps1 new file mode 100644 index 0000000..afaf932 --- /dev/null +++ b/SharedDscConfig/examples/init.ps1 @@ -0,0 +1,9 @@ +$ProjectPath = Get-item "$PSScriptRoot\..\.." + +if($Env:PSModulePath -split ';' -notcontains $ProjectPath) { + Write-Warning ">>> Adding $ProjectPath to `$Env:PSModulePath" + $Env:PSModulePath = $Env:PSModulePath +';'+ $ProjectPath.FullName +} + +#Now that the Variable has been set, you can call the DSC Test +. $PSScriptRoot\Default.ps1 From b6cb738f1b2bbac1c08e52af4eb5163a6456e862 Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Fri, 23 Mar 2018 22:06:43 +0000 Subject: [PATCH 6/7] updating the version of Chocolatey module to use --- README.md | 53 +++++++++---------- .../SoftwareBase/SoftwareBase.schema.psm1 | 2 +- 2 files changed, 25 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 19f7dea..c800ee3 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Using Geoffrey Moore's value proposition model: > >Our __configuration sharing guidelines__ is __a re-usable build process for DSC configurations__ > ->That __transforms Configuration into re-usable and composable DSC Composite Resources__ +>That ~~transforms Configuration into re-usable and composable DSC Composite Resources~~ allow configurations to be composed, following the [Datum](https://github.com/gaelcolas/Datum) model. @@ -53,54 +53,49 @@ Below are ideas I think worth discussing and suggestions of implementation. Plea ``` SHAREDDSCCONFIG +C:\SRC\SHAREDDSCCONFIG │ .build.ps1 -│ .gitignore -│ .kitchen.yml -│ appveyor.yml -│ LICENSE │ PSDepend.build.psd1 │ PSDepend.resources.psd1 -│ README.md │ ├───.build -│ README.md -│ ├───BuildOutput -│ README.md -│ ├───docs -│ └───media -│ ├───DSC_Resources -│ README.md │ └───SharedDscConfig │ SharedDscConfig.psd1 │ ├───DscResources - │ └───Shared1 - │ │ Shared1.psd1 - │ │ Shared1.schema.psm1 - │ │ - │ ├───ConfigData - │ │ │ Datum.yml - │ │ │ - │ │ └───common - │ │ SharedDscConfig.psd1 - │ │ - │ └───Diagnostics - │ ├───Comprehensive - │ └───Simple - │ SharedDscConfig.tests.ps1 + │ ├───Shared1 + │ │ │ Shared1.psd1 + │ │ │ Shared1.schema.psm1 + │ │ │ + │ │ ├───ConfigData + │ │ │ │ Datum.yml + │ │ │ │ + │ │ │ └───default + │ │ │ SharedDscConfig.psd1 + │ │ │ + │ │ └───Diagnostics + │ │ ├───Comprehensive + │ │ └───Simple + │ │ SharedDscConfig.tests.ps1 + │ │ + │ └───SoftwareBase + │ SoftwareBase.psd1 + │ SoftwareBase.schema.psm1 │ └───examples │ Default.ps1 + │ init.ps1 │ └───ConfigData │ Datum.yml │ - └───AllNodes - localhost.yml + └───TestSuites + OtherTestSuite.yml + SharedDscConfig.yml ``` The Shared Configuration should be self contained, but will require files for building/testing or development. The repository will hence need some project files on top of the files required for functionality. diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 index 14ca897..49e67bd 100644 --- a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 @@ -9,7 +9,7 @@ Configuration SoftwareBase { ) Import-DscResource -ModuleName PSDesiredStateConfiguration - Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.46 + Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.48 # Install Choco Software if not present ChocolateySoftware ChocoInstall { From 75c02835e0a0d5bee3efb386e221cef03a138a63 Mon Sep 17 00:00:00 2001 From: gaelcolas Date: Tue, 5 Feb 2019 11:16:39 +0800 Subject: [PATCH 7/7] Updating to latest Choco module --- .build.ps1 | 13 ++++++++----- PSDepend.build.psd1 | 2 +- PSDepend.resources.psd1 | 2 +- .../SoftwareBase/SoftwareBase.schema.psm1 | 8 ++++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.build.ps1 b/.build.ps1 index 002b09c..15f1279 100644 --- a/.build.ps1 +++ b/.build.ps1 @@ -19,7 +19,7 @@ Param ( $ForceEnvironmentVariables = [switch]$true, $MergeList = @('enum*',[PSCustomObject]@{Name='class*';order={(Import-PowerShellDataFile .\SampleModule\Classes\classes.psd1).order.indexOf($_.BaseName)}},'priv*','pub*') - + ,$CodeCoverageThreshold = 90 ) @@ -36,13 +36,16 @@ Process { Get-ChildItem -Path "$PSScriptRoot/.build/" -Recurse -Include *.ps1 -Verbose | Foreach-Object { "Importing file $($_.BaseName)" | Write-Verbose - . $_.FullName + . $_.FullName } task . DscClean,LoadResource,LoadConfigurations task DscClean { - Get-ChildItem -Path "$PSScriptRoot\$BuildOutput\" -Recurse | Remove-Item -force -Recurse -Exclude README.md + if(![io.path]::IsPathRooted($BuildOutput)) { + $BuildOutput = Join-Path $PSScriptRoot $BuildOutput + } + Get-ChildItem -Path $BuildOutput -Recurse | Remove-Item -force -Recurse -Exclude README.md } task Noop { } @@ -69,7 +72,7 @@ Process { begin { - + if (![io.path]::IsPathRooted($BuildOutput)) { $BuildOutput = Join-Path -Path $PSScriptRoot -ChildPath $BuildOutput } @@ -77,7 +80,7 @@ begin { if(($Env:PSModulePath -split ';') -notcontains (Join-Path $BuildOutput 'modules') ) { $Env:PSModulePath = (Join-Path $BuildOutput 'modules') + ';' + $Env:PSModulePath } - + function Resolve-Dependency { [CmdletBinding()] param() diff --git a/PSDepend.build.psd1 b/PSDepend.build.psd1 index 651de46..d90f460 100644 --- a/PSDepend.build.psd1 +++ b/PSDepend.build.psd1 @@ -19,6 +19,6 @@ PSScriptAnalyzer = 'latest' PlatyPS = 'latest' psdeploy = 'latest' - 'gaelcolas/DscBuildHelpers' = 'master' + DscBuildHelpers = 'latest' Datum = 'latest' } \ No newline at end of file diff --git a/PSDepend.resources.psd1 b/PSDepend.resources.psd1 index bc6fca6..26057d9 100644 --- a/PSDepend.resources.psd1 +++ b/PSDepend.resources.psd1 @@ -8,5 +8,5 @@ } } - Chocolatey = '0.0.46' + Chocolatey = '0.0.58' } \ No newline at end of file diff --git a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 index 49e67bd..1f47767 100644 --- a/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 +++ b/SharedDscConfig/DscResources/SoftwareBase/SoftwareBase.schema.psm1 @@ -4,13 +4,13 @@ Configuration SoftwareBase { $Sources = @(), $ChocolateyLicenseXml, $Settings = @(), - $Features = @(), + $Features = @(), $Packages = @() ) - + Import-DscResource -ModuleName PSDesiredStateConfiguration - Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.48 - + Import-DscResource -ModuleName Chocolatey -ModuleVersion 0.0.58 + # Install Choco Software if not present ChocolateySoftware ChocoInstall { Ensure = 'Present'