Am 19.01.2009 um 13:08 schrieb <sven.tho...@bt.com> <sven.tho...@bt.com>:
> 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? Go with a custom fact, either through an evironment variable on the clients, something like FACTER_NETWORK="net1", which will make a fact called $network available in your manifests, or "true" fact, for which I'd point you to the wiki. Another means would be to write a custom function, which would look somewhat like that (top of my head and not tested at all...): """ module Puppet::Parser::Functions newfunction(:network, :type => :rvalue) do |args| clientip = lookupvar('ipaddress') # this assigns $clientip the ipaddress fact of the current client ## Do some clever stuff with clientip, assign $clientnet some value clientnet end end """ The "clever stuff" obviously needs to be some ruby logic, either with nested if/elses or some matches, depending on what you feel most comfortable with. Felix Schäfer --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---