Forum: Cfengine Help Subject: Re: Sorting an slist Author: zzamboni Link to topic: https://cfengine.com/forum/read.php?3,22550,22579#msg-22579
Wes, Not very elegant, but you could define a list in the order you want and iterate over that instead of getting the indices from the array: "dns_idx" slist => { "0", "1", "2" }; You could also make the servers an slist instead of an array, for example: "siteconf" slist => { "10.9.72.50", "10.18.30.50", "10.32.28.30" }; and then iterate over that slist to insert the lines. If you really need the comment about each server, you could store them in an array indexed by the server's IP address. On the other hand, in this particular case, do you really care about the order? DNS servers should in principle be exchangeable, and in a large organization it's even good practice to have machines go to different servers as their first choice, to spread the load. Also, unless you are using empty_file_before_editing in your file-edit promises, the missing lines in the file will be inserted when needed, which may break the order in any case, if some other lines were already there. Best regards, _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine