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 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?
We use the KSMETA section of Cobbler and a custom fact script (which I've uploaded at http://tinyurl.com/368hccf ) to pull the data from this field. This approach means that we can create arbitrary key->value pairs that we can use as custom facts. As an example, we currently have the following custom facts available to us through this method: datacentre dc_rack dc_suite dc_room mysql_master and a few others including which databases are replicated by a given host etc. It's a lot easier than trying to split out IP Addresses etc and because KSMETA isn't hard-coded on build, it means that we can update these values when a server is moved etc. Hope this is of some help, I know it's not exactly what you're trying to do but it may be a worthwhile alternative. Kind regards, Matt -- 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.