Ask Your Question

puppet wildcard case $hostname [closed]

asked 2016-06-30 06:46:45 -0600

AvivMalka gravatar image


I would like create a class that says if your hostname includes the letters 'rob', it will assign a class to it. For example:

 class it_default {
    case $hostname {
      '*rob*':           { include robikun_base }

I have servers that called: SRV-Roben-01 Roben-02 IT-Roben10

I want to create a case for them and make the class file clean and simple and not putting all hostnames on the module file.


edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by AvivMalka
close date 2016-07-01 02:14:24.186418

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-30 09:04:18 -0600

maynero gravatar image

Using regular expression is your best bet, something like this.

case $hostname {
    /^.+\brob.+\b$/: { include robikun_base }

Also, if it is hostname, should you handle this in node?

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2016-06-30 06:46:45 -0600

Seen: 585 times

Last updated: Jun 30 '16