I have been testing DSC for some time to see if we can start using it instead of SCCM. There is a plenty of documentation around and setting up basic setup is trivial. The problem starts when I try to build something more complex.
Here is an example of what I am trying to achive. I have a feeling I am trying to achieve something that SCCM does well and DSC is not fit for.
Let’s say we have three servers and we build a configdata for them like below:
@{ AllNodes = @( @{ NodeName = "server1" Domain = "london.net" Datacenter = "uk2" Backup = "1" Monitored = "1" }, @{ NodeName = "server2" Domain = "atlanta.net" Datacenter = "us1" Backup = "0" Monitored = "1" }, @{ NodeName = "server3" Domain = "newyork.corp" Datacenter = "us3" Backup = "1" Monitored = "0" } ); NonNodeData = '' }
I would like to set up DSC to set up Backup and Monitoring for servers. Below are the examples of configuration. The configuration may use some logic and each server will have a specific settings for backup and monitoring required.
Monitoring configuration
$configurationName = "SCOMAgentConfiguration" configuration $configurationName { Import-DscResource -ModuleName cMMagent Node $AllNodes.Where({$_.Monitored -eq '1'}).NodeName { $dataCenter = $node.DataCenter $managementGroup = @{ "london.net" = "London" "atlanta.net" = "Atlanta" } } cMMAgentManagementGroups ManagementGroups { managementGroupName = $managementGroup.$($Node.domain) Ensure = 'Present' } } } &$configurationName -ConfigurationData (Import-PowerShellDataFile -Path ".\ConfigData.psd1")
Backup Configuration
$configurationName = "BackupFeatureEnable" configuration $configurationName { Node $AllNodes.Where({$_.Backup -eq '1'}).NodeName { WindowsFeature Backup { Name = 'Windows-Server-Backup' Ensure = 'Present' } } } &$configurationName -ConfigurationData (Import-PowerShellDataFile -Path ".\ConfigData.psd1")
As expected, I will have two folders containing mof files, “SCOMAgentConfiguration” and “BackupFeatureEnable”
Mof files are named as .mof.
I would like to be able to use information in these MOF files for configuring pull nodes.
This is where I can’t figure out what to do next. It seems that I want to have multiple Mof files per node and by the looks of thing this is not working.
I have tried partial configuration setup:
- Renamed mof files as below. I expected nodes to be able to read this format ( WMF5.1) but nodes complain about unavailable Partial config.
SCOMAgentConfiguration.server1.mof
SCOMAgentConfiguration.server2.mof
BackupFeatureEnable.server1.mof
BackupFeatureEnable.server2.mof
- Updated LCM for each server. As expected, this did not work and resulted in compilation errors about duplicate resources
[DSCLocalConfigurationManager()] Configuration LCMAgentConfiguration { Node $AllNodes.Where({$_.Monitored -eq '1'}).NodeName { ConfigurationRepositoryWeb PullServer { ServerURL = $Node.ServerURL ConfigurationNames = @("SCOMAgentConfiguration") } PartialConfiguration SCOMAgentConfiguration { Description = "SCOMAgentConfiguration" ConfigurationSource = @("[ConfigurationRepositoryWeb]PullServer") } } Node $AllNodes.Where({$_.Backup -eq '1'}).NodeName { ConfigurationRepositoryWeb PullServer { ServerURL = $Node.ServerURL ConfigurationNames = @("BackupFeatureEnable") } PartialConfiguration BackupFeatureEnable { Description = "BackupFeatureEnable" ConfigurationSource = @("[ConfigurationRepositoryWeb]PullServer") } } } LCMAgentConfiguration -ConfigurationData (Import-PowerShellDataFile -Path ".\ConfigData.psd1")
Is it even possible to achieve such setup where I can add configurations incrementally?
It is definetly possible in SCCM. I can add Backup configuration setup for hosts that need to be backed up. Then I add set up Monitoring for hosts that requre it. Both operations are independent.
Maybe I need to rethink the entire approach as DSC concepts are way too different from SCCM?