On Tue, Apr 5, 2011 at 3:48 PM, Jacob Helwig <ja...@puppetlabs.com> wrote:
> On Tue, 05 Apr 2011 15:24:12 -0700, Jeffrey wrote:
>>
>> Hi folks,
>>
>> Does anyone know how to do case-insensitive regex in a puppet
>> manifest?  I tried obvious things, like adding an 'i' at the end of my
>> regex (ala perl) but that didn't work.
>>
>> if ($operatingsystem =~ /(centos|redhat|oel)/) {
>> ...
>> }
>>
>> The following works (for centos), but it's a bit clunky,
>>
>> if ($operatingsystem =~ /([Cc][Ee][Nn][Tt][Oo][Ss]|redhat|oel)/) {
>> ...
>> }
>>
>> For completion, I found the 'downcasefacts' directive in puppet.conf,
>> but that's not really what I want.  (Plus, 'downcasefacts' is
>> deprecated anyway.)
>>
>
> After talking with Nick Lewis, we suspect that the following will work:
>
>  if ($operatingsystem =~ /((?i:centos)|redhat|oel)/) {
>  ...
>  }

You can obtain the regex string that will work in Puppet via irb to_s:

/(centos|redhat|oel)/i.to_s
=> "(?i-mx:(centos|redhat|oel))"

Thanks,

Nan

-- 
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