gaelcolas / datum

Hierarchical data meta structure
MIT License
161 stars 35 forks source link

RSOP not including LcmConfig (because it's static) #75

Closed raandree closed 2 years ago

raandree commented 5 years ago

Usually every bit of config data is visible in the RSOP output. But the LCM settings are missing the pull server URI and the RegistrationKey which is in the Meta MOFs (so it does exist) but not in the RSOP.

A repo is here: https://github.com/raandree/DatumTest

The RSOP output for node PreServer1

Environment: Pre
Description: CoreDC in CSPre
Name: PreServer1
PSDscAllowPlainTextPassword: true
LcmConfig:
  ConfigurationRepositoryWeb:
    Server:
      ConfigurationNames: PreServer1
SoftwarePackages:
  Package:
  - Name: Password Policy Enforcer 9.1
    Ensure: Present
    Path: D:\Packages\PPE\PPE910.msi
    ProductId: 55EBFC31-1031-463C-A870-416E2C312A64
PSDscAllowDomainUser: true
Configurations:
- FilesAndFolders
- SoftwarePackages
- WindowsFeatures
Role: CoreDC
WindowsFeatures:
  Name:
  - -Telnet-Client
FilesAndFolders:
  Items:
  - DestinationPath: C:\Test\Frankfurt
    Type: Directory
Location: Frankfurt
NodeName: PreServer1

The meta.mof with the content that is missing in RSOP.

/*
@TargetNode='PreServer1'
@GeneratedBy=randr
@GenerationDate=08/30/2019 13:24:26
@GenerationHost=RAANDREE0
*/

instance of MSFT_WebDownloadManager as $MSFT_WebDownloadManager1ref
{
SourceInfo = "::6::2::ConfigurationRepositoryWeb";
 ServerURL = "https://PrePull.contoso.com/PSDSCPullServer.svc";
 ResourceID = "[ConfigurationRepositoryWeb]Server";
 RegistrationKey = "fbc6ef09-ad98-4aad-a062-92b0e0327562";
 ConfigurationNames = {
    "PreServer1"
};

};

instance of MSFT_WebReportManager as $MSFT_WebReportManager1ref
{
SourceInfo = "::6::2::ReportServerWeb";
 ServerURL = "https://PrePull.contoso.com/PSDSCPullServer.svc";
 ResourceID = "[ReportServerWeb]ReportServerWeb";
 RegistrationKey = "fbc6ef09-ad98-4aad-a062-92b0e0327562";

};

instance of MSFT_DSCMetaConfiguration as $MSFT_DSCMetaConfiguration1ref
{
RefreshMode = "Pull";
 AllowModuleOverwrite = True;
 ActionAfterReboot = "ContinueConfiguration";
 RefreshFrequencyMins = 30;
 RebootNodeIfNeeded = True;
 ConfigurationModeFrequencyMins = 30;
 ConfigurationMode = "ApplyAndMonitor";

  ReportManagers = {
  $MSFT_WebReportManager1ref  
 };
  ConfigurationDownloadManagers = {
  $MSFT_WebDownloadManager1ref  
 };
};

instance of OMI_ConfigurationDocument
{
 Version="2.0.0";
 MinimumCompatibleVersion = "2.0.0";
 CompatibleVersionAdditionalProperties= { "MSFT_DSCMetaConfiguration:StatusRetentionTimeInDays" };
 Author="randr";
 GenerationDate="08/30/2019 13:24:26";
 GenerationHost="RAANDREE0";
 Name="RootMetaMOF";
};

Is this by design or does something go wrong?

gaelcolas commented 5 years ago

Yeah, by design. Can be suboptimal but not a lot of effort has been put in Get-DatumRsop. In short, this function only lookup based on the Configurations pivot.

For a given node it resolves the array of configurations items from the 'configurations' key. Then for each configuration, does a lookup of that config for that node and merge into the root node element.

So it builds the rsop by doing a Lookup foreach item in the configurations key, because that's the only thing we know (the pivot).

If we'd want to add the LCM configs, we ought to do something similar than what you can find in RootMetaMof.ps1: Adding here the following...

$RSOPNode.Add('LcmConfig',@{})
'LcmConfig\Settings','LcmConfig\ConfigurationRepositoryShare','LcmConfig\ResourceRepositoryShare','LcmConfig\ConfigurationRepositoryWeb','LcmConfig\ResourceRepositoryWeb','LcmConfig\ReportServerWeb','LcmConfig\PartialConfiguration' | % { $KeyToAddToNode = Resolve-NodeProperty -PropertyPath $_ -DefaultValue $null; $RSOPNode.LcmConfig[$_] = $KeyToAddToNode;  }

This is rough and not tested, but illustrates the idea :)

raandree commented 2 years ago

Solved in b7da69decf6255df6b98c8e504ad7c5dda5220f6.