Puppet node name with regex

puppetregex

I am running puppet 3.7.3 on a windows 8.1 client and it is pulling in my default node definition.

I am trying to create a more generalized definition by using regex on a group of nodes. Our naming scheme is similar to: bldg-50zx022-1.domain.tld. For my node definition, I am using the below, but I never see the info when I run puppet agent -td

node /^(bldg|BLDG)-\w{0,7}-\d+/ {
    info("inside node definition")
}

I have verified that my regex is correct using rubular.com. When I run facter, I get these values:

fqdn => BLDG-50ZX022-2.domain.tld
hostname => BLDG-50ZX022-2

Is there anything I can do to get this to work?

Best Answer

So I'm not sure how the puppet engine handles the grouping, but (bldg|BLDG) is technically a capture group, so some regex engines will return only that capture group.

When running it through regex101.com, I figured this would do your bldg/BLDG OR while capturing the whole hostname as the only capture group, give it a shot:

/^((?:bldg|BLDG)-\w{0,7}-\d+)/
Related Topic