Tech documentation is littered with examples that illustrate exactly
one thing and call it day. 99% of the power of any system comes from
learning to combine multiple functions. I chose that example because
it illustrates regex, using regex in a node as well as case
statements, adding classes based on case statements, setting a default
in a case statement, and should have the OP considering that Puppet
can do more then 1:1 mapping. Getting past the 1:1 mapping idea seems
to take most traditional sysadmins or non CS types longer. Simply,
demonstrating possibilities was more important than least keystrokes.
Also my example avoids first match problems. Yours does as well
assuming it was clear that the first statement *had* to be first. That
is probably the number #2 mistake of documentation, illustrating a
concept without exploring the assumptions of the example.

Ramin

On Nov 17, 10:47 am, Jo Rhett <jrh...@netconsonance.com> wrote:
> On Nov 16, 2011, at 11:08 AM, Ramin K wrote:
>
>
> > You can also use regex in your node files to further simplify though
> > if you're doing a lot of logic here you should probably start thinking
> > about an ENC.
>
> > fe.pp
> > node /^fe\d+(.*)/ inherits basenode {
>
> >  case $::fqdn {
> >    /(.*)stage|demo(.*)/: {
> >      include hostgroup::frontend::stage
> >    }
> >    default: {
> >      include hostgroup::frontend::prod
> >    }
> >  }
> > }
>
> Ramin, curious as to how this differs from the shorter …?
>
> node /^fe\d+(.*)(stage|demo)(.*)/ inherits basenode {
>      include hostgroup::frontend::stage}
>
> node /^fe\d+(.*)/ inherits basenode {
>      include hostgroup::frontend::prod
>
> }
>
> I love regexs too, but that seems to be excessive syntax.
> (and FYI, you forgot parens around the | …)
>
> --
> Jo Rhett
> Net Consonance : consonant endings by net philanthropy, open source and other 
> randomness

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to