Jonathan Gazeley
2011-Jun-24 14:15 UTC
[Puppet Users] IP address evenness as an identifier
For my puppet-managed servers, I want roughly half to use nameserver1 followed by nameserver2, and the other half to use nameserver2 in preference to nameserver1. The most reliable and simplest way I can think of doing this is to look at the last octet of the IP address, test whether it is even or odd, and apply different nameservers accordingly. Two questions: how would this be easily achieved in a manifest, and is there a better way? :) Cheers, Jonathan -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jun 24, 2011, at 7:15 AM, Jonathan Gazeley wrote:> For my puppet-managed servers, I want roughly half to use nameserver1 followed by nameserver2, and the other half to use nameserver2 in preference to nameserver1. > > The most reliable and simplest way I can think of doing this is to look at the last octet of the IP address, test whether it is even or odd, and apply different nameservers accordingly. > > Two questions: how would this be easily achieved in a manifest, and is there a better way? :)---- I would probably create a custom fact for this IP_ADDR="192.168.10.21" y=#{IP_ADDR}.split(''.'')[3].to_i).divmod(2)[1] puts y something like... $resolv.conf_pool = "resolv.conf-pool-A" #{IP_ADDR}.split(''.'')[3].to_i).divmod(2)[1] == 0 ? "resolv.conf-pool-A" : "resolv.conf-pool-B" and then ''source'' the actual resolv.conf file per pool-A or pool-B result Should be relatively easy to create. -- Craig White ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ craig.white@ttiltd.com 1.800.869.6908 ~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ttiassessments.com Need help communicating between generations at work to achieve your desired success? Let us help! -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Jun 24, 9:15 am, Jonathan Gazeley <jonathan.gaze...@bristol.ac.uk> wrote:> For my puppet-managed servers, I want roughly half to use nameserver1 > followed by nameserver2, and the other half to use nameserver2 in > preference to nameserver1. > > The most reliable and simplest way I can think of doing this is to look > at the last octet of the IP address, test whether it is even or odd, and > apply different nameservers accordingly. > > Two questions: how would this be easily achieved in a manifest, and is > there a better way? :)If your name resolver supports it then you could put options rotate into every /etc/resolv.conf (or add ''rotate'' to the existing options) so that all hosts alternate which name server they query first. If that works for you at all then it should do a better job of spreading out the name service load than would tweaking the name server listing order on some of your machines. It''s also a lot easier to code in your manifests. John -- 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+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.