Ask Your Question
0

puppet wildcard case $hostname [closed]

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

AvivMalka gravatar image

Hi,

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.

Thanks

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
2

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

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

Stats

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

Seen: 168 times

Last updated: Jun 30 '16