If I understand the match function on strings properly you might want to escape the periods in your logic:
10.1.1. matches 10.1.1.X and 10.101.X for instance. On Wed, Jan 21, 2009 at 6:58 AM, <sven.tho...@bt.com> wrote: > > Thank you for your input! I solved it like this in then end: > > Facter.add("netenv") do > setcode do > begin > Facter.ipaddress > rescue > Facter.loadfacts() > end > distid = Facter.value('ipaddress') > if distid.match(/10.1.1.|172./) > network = "net1" > elsif distid.match(/10.2.2./) > network = "net2" > elsif distid.match(/10.3.3./) > network = "dmz" > else > network = "unknown" > end > network > end > end > > > Sven > > -----Original Message----- > From: puppet-users@googlegroups.com [mailto:puppet-us...@googlegroups.com] On > Behalf Of Jeff Leggett > Sent: Tuesday, January 20, 2009 7:52 PM > To: Puppet Users > Subject: [Puppet Users] Re: Pattern matching in case statement > > > I just did something similar to parse out what proxy my client should > use - for a custom fact do: > > Facter.add(:network) do > setcode do > srcIP = Facter.value(:ipaddress) > octets = srcIP.split (/\./ ) > > <logic specific to your use> > > end > end > > On Jan 19, 7:08 am, <sven.tho...@bt.com> wrote: >> Hi all, >> >> I need my servers to decide which network they are in (i.e. dmz), and >> the only clue is the servers IP-address. I was trying to accomplish it >> like this, but it doesn't work: >> >> case $ipaddress { >> >> "10.1.1.*": { >> >> $network = "net1" >> >> } >> >> "10.2.2.*.*": { >> >> $network = "net2" >> >> } >> >> "10.3.3.*": { >> >> $network = "net3" >> >> } >> >> } >> >> When I change the IP Address to a valid one (like 10.1.1.100) the case >> works and the network variable is set accordingly. What's the correct >> way to do this? >> >> Thanks a bunch, >> >> Sven > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---