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
}