puppet - define wildcard host in nodes.pp

Solution 1:

Not in this way. You can create a 'default' node that will apply to any signed client.

node "default" {
   include foo
}

But you can only have 1 default. If you want to replicate the functionality you describe you can use the external_nodes method of classification. Basically you write a script that returns valid yaml when a client connects. That script can do it anyway you want, check fqdn, query a db, hit ldap, etc.

Solution 2:

Regular expressions are now possible in Puppet 0.25, so what you want would be possible:

node /^(foo|bar)\.example\.com$/ {
include blah
}

Solution 3:

Few distros ship 0.25 as of yet, so in my Centos5 having 2.24.8 from the EPEL repo I had to do something like this for my worker nodes with hostnames like wn10.example.com:

node  default {
    $node_type = regsubst($hostname, '^([a-z]+).*$', '\1')
    case $node_type{
        wn: {include worker_node}
        default: {include generic_node}
    }
}