I did just notice this line, which should remove the .shuffle so it's consistent on every run:
server_list = @_ldap_servers.shuffle Rob Nelson rnels...@gmail.com On Mon, Jul 24, 2017 at 7:45 AM, Martijn <mart...@heemels.com> wrote: > I think that's perfect for the OP's use case. And if you need multiple > random numbers there's a useful second parameter to fqdn_rand(), the > "seed", which can be any string or integer and allows you to get multiple > different random numbers on the same host. > > So, you could use the server_list.size as the seed to get a different but > number after you pop off an item from your server_list array. > -- > Martijn > > Op zondag 23 juli 2017 16:51:17 UTC+2 schreef Rob Nelson: >> >> 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 <mizuk...@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...@googlegroups.com. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/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/63df98a6-ec85-4976-b300-0e3482857c99%40googlegroups.com > <https://groups.google.com/d/msgid/puppet-users/63df98a6-ec85-4976-b300-0e3482857c99%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAC76iT9gQUG1m%3DK6-V%3DnOCNoVtd_cyGG%3DMjbgeMjKF31J5P6rA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.