Recusrive DSC Composite Modules

I've been learning a lot about how to use Azure Automation to manage DevOps deployments of our Windows Servers. This has led me to a dozen DSC modules, some with two dozen configurations within them. This led to all of the composite build files having dozens of lines duplicated between all of them, and me wanting to further abstract the baseline configuration even further. All you need to do is import the module from within a resource and set your defaults.


Your DSC module structure needs to be the same as always:

PRIVATE.DSC.WINDOWS.DOMAINCONTROLLER
|   DSC.Windows.DomainController.psd1
|
\---DSCResources
    +---DomainControllerCommon
    |       DomainControllerCommon.psd1
    |       DomainControllerCommon.schema.psm1
    |
    +---DomainControllerCommonDefaults
    |       DomainControllerCommonDefaults.psd1
    |       DomainControllerCommonDefaults.schema.psm1
    |
    +---DomainControllerDesktop
    |       DomainControllerDesktop.psd1
    |       DomainControllerDesktop.schema.psm1
    |
    +---DomainControllerDHCPServer
    |       DomainControllerDHCPServer.psd1
    |
    +---DomainControllerFirewall
    |       DomainControllerFirewall.psd1
    |       DomainControllerFirewall.schema.psm1
    |
    +---DomainControllerNLA
    |       DomainControllerNLA.psd1
    |       DomainControllerNLA.schema.psm1
    |
    \---DomainControllerRegistry
            DomainControllerRegistry.psd1
            DomainControllerRegistry.schema.psm1

Each of these .psm1's contain their own portion of the composite configuration, then within the DomainControllerCommonDefaults.psm1 file we've got the following:

Configuration DomainControllerCommonDefaults {
    Import-DSCResource -ModuleName "PRIVATE.DSC.Windows.DomainController"
    
    DomainControllerCommon SetDCCommon {}
    DomainControllerFirewall SetDCFirewall {}
    DomainControllerNLA SetNLANetLogonDependencies {}
    DomainControllerRegistry SetDCRegistryEntries {}
}
```

Then in the DC configuration file instead of the four settings we can just use:

DomainControllerCommonDefaults SetCommonDCDefaults {}