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] ), to
give 192.168.

So, in your case, I guess something like <%= ipaddress.split(".")[1] %>
should work.


On Thu, Oct 14, 2010 at 7:27 PM, Dennis vdM <cybernijn...@gmail.com> 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 of digits, but maybe there
> is a way?
>
> I've already tried to make a custom fact, but my ruby knowledge is
> *ahem* pretty basic.
> So far I've only managed to manipulate a string with chop!, but that
> really isn't the way.
> Regular expressions in Ruby are a bit of a mystery to me....
>
> Ideas anyone?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To post to this group, send email to puppet-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@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-us...@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