Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.