On Sep 18, 2013, at 12:33 PM, Mike Reed <[email protected]> wrote:

> Hello all,
> 
> I've been fighting a pesky regex issue and I was hoping somebody might have a 
> solution handy.  I'm trying to evaluate the hostname variable based on a few 
> regex entries and apply some configurations accordingly.
> 
> Here's what I've got:
> 
> if ($hostname == '/^([a-z]*[-]\d{2,})*$/') or ($hostname == 
> '/^([a-zA-Z0-9])*$/') {
> 
> another variant: 
> 
> if ($hostname == '/^([a-z]*[-]\d{2,})*$/') || ($hostname == 
> '/^([a-zA-Z0-9])*$/') {
> 
> I expect the second option to work as it seems - according to my reading - to 
> be more "ruby friendly".
> 
> Has anybody used this syntax successfully in the past?  Additionally, I 
> suspect I could be bastardizing this as I'm not familiar with ruby.
> 
> Thanks in advance for the help.
> 
> Cheers,
> 
> Mike

Since you're doing regex matching you need to use the '=~' operator instead of 
'==', like so:

if ( $::hostname =~ /^foo/ ) or ( $::hostname =~ /^bar/ ) {

--
Peter Bukowinski

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to