Hi,

I use something like this.

...
hostnamevar.scan(/^\d+-qa-/)
...

Here is the best tool on the planet for writing and testing regexes:

http://www.rubular.com

Den
On 25/08/2011, at 11:43, newguy <aimanparv...@gmail.com> wrote:

> Hi guys
> I have a custom fact envt, it was working fine but now I have to make
> some changes in it;
> puppet client's hostname is of the type 1234qa-abc-de.local where 1234
> can be any thing of any length.My custom fact should contain qa, ie I
> want to check in the first part(before the first -) of the hostname
> if  there exists a pattern/word qa and if it exists then my custom
> fact
> for envt should be qa.
> 
> My old envt.rb code is:
> 
> require 'facter'
> Facter.add("envt") do
>        setcode do
>                %x{hostname -s|cut -c 1-2}.chomp
>        end
> end
> 
> I am not good with regex/ patterns please help me out guys.
> Thanks
> 
> -- 
> 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.
> 

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