On Oct 5, 2011, at 7:38 PM, CZACHOR, KRISTOPHER wrote: > Hi all, > > I’m trying to wrap my brain around this one and could use a little > help/guidance. I have need to deploy software based on the network a system > is in. > > Has anyone had need or been able to do the following?: > > (Pseudo code) > If 123.123.123.123 is in 123.123.123.0/24 or 234.234.234.234.0/24 > (list/array of networks it could belong to) then ensure package is present. > -or- > If 123.123.123.123 is in 123.123.123.0/255.255.255.0 then ensure package is > present. > > Yes I suppose a case statement would work better. > > Now I know from Facter I have the following _easily_ at my disposal: > ipaddress and netmask. As easy as it would be to use the network_eth0 to get > what network the host is in I’m a little hesitant to go down that route since > I can’t rely on the eth0 part network_eth0 being consistent. Fedora 15, for > example, is using a new naming convention for their Ethernet interfaces. Mine > is em1. I suppose I could figure out the eth0/em1 part by using the ipaddress > and interfaces fact and use it to figure out the network_eth0/em1 and that > would give me the network address. But this just seems like really too much > freakin’ work. > > Anyone have anything simple and elegant? Is there some glaring feature of > puppet/facter that I’ve overlooked that says …”Duh!” > > As always any help in advance is appreciated, ---- create a custom fact...
Facter.add("datacenter") do setcode do datacenter = "unknown" # Get current ip address from Facter's own database ipaddr = Facter.value(:ipaddress) # A data center if ipaddr.match("^10\.3\.") datacenter = "A" # C data center elsif ipaddr.match("^10\.1\.") datacenter = "C" # D data center elsif ipaddr.match("^10\.0\.") datacenter = "D" # E data center elsif ipaddr.match("^10\.2\.") datacenter = "E" # F data center elsif ipaddr.match("^10\.10\.") datacenter = "F" end datacenter end end deploy based on custom fact... case $datacenter { default: { $ldap_servers = "ldap://ldap2.example.com ldap://ldap1.example.com" } A: { $ldap_servers = "ldap://ldap1.example.com ldap://ldap2.example.com" } B: { $ldap_servers = "ldap://ldap1.example.com ldap://ldap2.example.com" } Craig -- 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.