Matthias Kellermann
2012-Dec-04 16:44 UTC
[Puppet Users] Use random value from an array in a template
Hi there, I have a network service with three IP addresses. For my client config file I want to choose a random IP addresses of the three available addresses (round robin via DNS won''t work..). Is there a way to use a random IP from an array in a puppet template? Thanks and best regards, Matthias -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8PrcZfi0VMkJ. 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.
Nikola Petrov
2012-Dec-04 17:00 UTC
Re: [Puppet Users] Use random value from an array in a template
You should really think about this more closely. Imagine you had the *rand* function that gives you an integer from 1..3 now if you define $ipaddress = rand() in your manifest you will now generate a new ipaddress on each puppet agent run. If you want that we can tell you how to do it(I even think it is in the example at puppet custom function) P.S. I had to learn this the hard way by trying to balance a cassandra cluster with proper initial_tokens. Best, Nikola On Tue, Dec 04, 2012 at 08:44:03AM -0800, Matthias Kellermann wrote:> Hi there, > > I have a network service with three IP addresses. For my client config file > I want to choose a random IP addresses of the three available addresses > (round robin via DNS won''t work..). > > Is there a way to use a random IP from an array in a puppet template? > > Thanks and best regards, > Matthias > > -- > You received this message because you are subscribed to the Google Groups "Puppet Users" group. > To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/8PrcZfi0VMkJ. > 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. >-- 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.
Jeff McCune
2012-Dec-04 23:02 UTC
Re: [Puppet Users] Use random value from an array in a template
On Tue, Dec 4, 2012 at 8:44 AM, Matthias Kellermann <matthias.kellermann@gmail.com> wrote:> Hi there, > > I have a network service with three IP addresses. For my client config file > I want to choose a random IP addresses of the three available addresses > (round robin via DNS won''t work..). > > Is there a way to use a random IP from an array in a puppet template?The fqdn_rand function will consistently return a number seeded with the fully qualified domain name. You''ll get back the same number every time you execute this function when compiling a catalog for host provided the fqdn of the host is static. http://docs.puppetlabs.com/references/latest/function.html#fqdnrand -Jeff -- 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.