You could try fqdn_rand(). Fqdn_rand will generate a random number, but the same random number for a given fqdn, so you would get the same value every time rather than it changing. https://docs.puppet.com/puppet/latest/function.html#fqdnrand
On Sun, Jul 23, 2017 at 1:20 AM MK <mizuki0...@gmail.com> wrote: > Does anyone have experiences randomizing the order of redundant server > names in the client configuration and won't change the order during next > puppet agent runs? > > For example, I have a bunch of ldap slave servers put in an array: > > $_ldap_servers = ['ldap1' , 'ldap2', 'ldap3'] > > I want to randomize the order in the client config (ex, nslcd.conf or > sssd.conf ) so they don't always hit the same ldap server. > > ex: > ldap_search_base = dc=example, dc=com > ldap_uri = ldaps://ldap2 ldaps://ldap0 ldaps://ldap3 > > What I did so far is that in the ERB template, I put the following code: > ```` > ldap_uri = <% > server_list = @_ldap_servers.shuffle > server_list.size.times do > server = server_list[rand(server_list.size)] -%>ldaps://<%= server > -%>/ <% > server_list.delete(server) > end %> > ``` > It was working well with Rack based puppetmaster 3.x, but after upgrading > to puppetserver 2.7.x, it changes the order every time when agent runs. > > Does anyone have any suggestions? > Thanks so much! > > MK > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to puppet-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/cfe4921b-d777-4b9e-8b6a-473f7c1904a5%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/cfe4921b-d777-4b9e-8b6a-473f7c1904a5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Rob Nelson -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAC76iT9nXLw1N2YeNuwfQ%2BHT3YFJqGU-vuCOpT-jLKAtHLULkQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.