7

See my node's configuration:

 $property_name = {
     "unit_1"  => { host => [ "dns_name1/192.168.0.1/25" ,"dns_name2/192.168.0.2/25" ] 
                  },
     "unit_2"  => { host => [ "dns_name3/192.168.0.3/25", "dns_name4/192.168.0.4/25" ] 
                  },
 }
 include class::property

In the template, I used some loop with

"<% property_name.each do |key,value| -%>", 
"<%= value['host'][id_host].split("/")[0] %>", 
 <%= value['host'][id_host].split("/")[1] %>,

... to write config files.

But, when I have a lot of "units" (unit_3, unit_4, etc.) the template's content changed every time Puppet's daemon runs.

It didn't have any impact because the config file is correct but I would like to know if the template's loop could generate config files in this order : unit_1 then unit_2, then unit_3, ... without to take some unit randomly.

I used this tutorial : http://www.krzywanski.net/archives/703

9

You should be able to use Ruby to sort the values inline to provide consistent results:

"<% property_name.sort_by {|key, value| key}.each do |key, value| -%>"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.