Re: [Puppet Users] manipulating facter variable

2010-10-14 Thread Nigel Kersten
On Thu, Oct 14, 2010 at 9:48 AM, Mohit Chawla wrote: > > > On Thu, Oct 14, 2010 at 9:55 PM, Nigel Kersten > wrote: >> >> On Thu, Oct 14, 2010 at 7:18 AM, Mohit Chawla >> wrote: >> > Split & Join inside an inline template should work well. >> >> Wouldn't it be a bit cleaner to use the builtin reg

Re: [Puppet Users] manipulating facter variable

2010-10-14 Thread Mohit Chawla
On Thu, Oct 14, 2010 at 9:55 PM, Nigel Kersten wrote: > On Thu, Oct 14, 2010 at 7:18 AM, Mohit Chawla > wrote: > > Split & Join inside an inline template should work well. > > Wouldn't it be a bit cleaner to use the builtin regsubst function? > > http://docs.puppetlabs.com/references/latest/funct

Re: [Puppet Users] manipulating facter variable

2010-10-14 Thread Nigel Kersten
On Thu, Oct 14, 2010 at 7:18 AM, Mohit Chawla wrote: > Split & Join inside an inline template should work well. Wouldn't it be a bit cleaner to use the builtin regsubst function? http://docs.puppetlabs.com/references/latest/function.html#regsubst "Example: Get the third octet from the node’s I

Re: [Puppet Users] manipulating facter variable

2010-10-14 Thread Matt Wallace
On Thursday 14 Oct 2010 14:57:08 Dennis vdM wrote: > I'm trying to manipulate the following facter variable: > > ipaddress => 10.85.207.2 > > What I need is the second group of digits. If it's 84 then location is > A, but if it's 85 then location is B. > In puppet I couldn't grab this second set

Re: [Puppet Users] manipulating facter variable

2010-10-14 Thread Mohit Chawla
Split & Join inside an inline template should work well. For eg., $nsip=inline_template('<%= ipaddress.split(".")[0..1].collect{|x| x}.join(".") %>') This will split an ip address, say 192.168.1.3, split it at each occurrence of a "." and will join the first two numbers ( referenced as [0..1] ),

[Puppet Users] manipulating facter variable

2010-10-14 Thread Dennis vdM
I'm trying to manipulate the following facter variable: ipaddress => 10.85.207.2 What I need is the second group of digits. If it's 84 then location is A, but if it's 85 then location is B. In puppet I couldn't grab this second set of digits, but maybe there is a way? I've already tried to make