<% Array(@ipaddresses).zip(Array(@server_names)).each do |ipaddress,host| -%>
  server <%= host %> <%= ipaddress %>:<%= Array(@ports).collect {|x|x.split(',')}.flatten.join(",#{ipaddress}:") %> <%= if @define_cookies then "cookie " + host end %> <%= Array(@options).join(" ") %>
<% end -%>

<% Array(@ipaddresses).zip(Array(@server_names)).each do |ipaddress,host| -%>
  server <%= host %> <%= ipaddress %>:<%= Array(@ports).collect {|x|x.split(',')}.flatten.join(",#{ipaddress}:") %> <%= if @define_cookies then "cookie " + host end %> <%= Array(@options).sort.join(" ") %>
<% end -%>

Fix ordering of options changing
Fix ordering of options changing

The order of the options kept changing on each puppet run for me. Adding the sort makes the order consistent on each puppet run.