Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

See my node's configuration:

 $property_name = {
     "unit_1"  => { host => [ "dns_name1/" ,"dns_name2/" ] 
     "unit_2"  => { host => [ "dns_name3/", "dns_name4/" ] 
 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 :

share|improve this question
up vote 9 down vote accepted

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| -%>"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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