Search code examples
powershellazuredscazure-automation

How to use "*" in nodeName


Say I have 2 roles in my DSC setup and I have variable amount of nodes in my setup:

$configdata = @{
    AllNodes = @(
        @{
            NodeName = "*Web*" # < problem lies here
                      # can be prodWeb## or devWeb##
            Role = "IIS", "basic"
        }
        @{
            NodeName = "*"
            Role = "basic"
        }
    )
}

DSC resource:

Configuration CFG
{   
    $AllNodes.where{ $_.Role.Contains("Basic") }.NodeName 
    {
    ...
    }

    $AllNodes.where{ $_.Role.Contains("IIS") }.NodeName 
    {
    ...
    }
}

Can I achieve that?


Solution

  • So, basically what I've done is this:

    Configuration Windows
    {   
        node $allnodes.NodeName {
            switch ($Node.Role) {
                "Role1" {
                    ...
                }
                "Role2" {
                    ...
                }
                "Role3" {
                    ...
                }
            }
        }
    }
    

    My configuration data:

    @{ AllNodes = @( @{ NodeName = "web"; Role = "Role1", "Role2" } ) }
    

    And for another set of nodes:

    @{ AllNodes = @( @{ NodeName = "other"; Role = "Role1", "Role3" } ) }
    

    I'm using Azure Automation to assign configurations to nodes, so it doesn't check the node name, it just applies whatever roles the configuration had at compile time.