Author Posts

May 20, 2015 at 1:03 pm

I have a rather large "common" configuration I want to apply to all nodes. However, before I configure a role I need to wait for that common configuration to be applied. So I imagined something like this:

Configuration CommonConfiguration
{
BaseConfiguration Base
{
EnvironmentName = $Node.EnvironmentName
}
}

Configuration Fubar
{
Node $AllNodes.NodeName
{
CommonConfiguration Common {}
}

Node $AllNodes.Where{$_.Role -eq 'Role'}.NodeName
{
RoleConfiguration Role { DependsOn = "[CommonConfiguration]Common" }
}
}

Unless I was doing something wrong, this didn't work for me. I also had issues referencing the $Node variable from within the CommonConfiguration resource configurations. I also tried just putting the CommonConfiguration inside each role definition but that produced similar errors with references for DependsOn elements being not found.

I'll be the first to admit I am still extremely green when it comes to DSC so I could be "missing" some concept here. I basically would like to avoid having to include all the common configuration in multiple role definitions because it is rather large already.

I did "hack" it, even though it works well, I'm not satisfied with this being the answer:

Node $AllNodes.Where{$_.Role -eq 'Primary'}.NodeName
{
Invoke-Expression (Get-Item function:CommonConfiguration).Definition
}

May 20, 2015 at 3:59 pm

I am perhaps running into a known issue with DSC in WMFv4: https://connect.microsoft.com/PowerShell/feedback/details/812943/dsc-cannot-set-dependson-to-a-nested-configuration

Does anyone know if this is resolved in WMFv5?

May 20, 2015 at 5:07 pm

So another workaround is I created a resource called xDscJunction. It does nothing but acts as a single exit point of the Node $AllNodes.NodeName configuration that the other Node role definitions can leverage as a dependency:

Configuration Fubar
{
    Node $AllNodes.NodeName
    {
        xIPAddress Ethernet_IPAddress { ... }
        cNetAdapterAdvancedProperty Ethernet_Netflow { ... }
        cDscJunction CommonConfiguration {
            DependsOn = '[xIPAddress]Ethernet_IPAddress','[cNetAdapterAdvancedProperty]Ethernet_Netflow'
        }
    }

    Node $AllNodes.Where{$_.Role -eq 'Role'}.NodeName
    {
        xService MSiSCSI { ... DependsOn = '[cDscJunction]CommonConfiguration' }
    }
}


From what I can tell from inspecting the MOF it looks like this did exactly what I wanted though building a hierarchy of composite configurations is going to get more difficult until that bug gets fixed.