Forum: Cfengine Help
Subject: Should getindices provide the same order every time?
Author: bbomgardner
Link to topic: https://cfengine.com/forum/read.php?3,20408,20408#msg-20408

I've noticed that once in a blue moon some of my config file promises using the 
getindices function come out in a different order.  In particular, I have seen 
this happen with the postfix example from 
http://www.cfengine.org/manuals/cf3-solutions.html#Postfix-mail-configuration:


bundle agent mta
{
files:

    "/etc/postfix/main.cf"
      handle                 =>     "postfix_main_cf",
      comment                =>     "Ensure correct postfix configurations.",
      edit_line              =>     postfix_config,
      classes                =>     if_repaired("restart_postfix");

commands:

  restart_postfix::
    "/etc/init.d/postfix restart"
      handle            =>     "restart_postfix_init",
      comment           =>     "Instruct postfix to re-read its configuration.";

}

bundle edit_line postfix_config
{
vars:

  "ps" string         =>     "mail.domain.com)";
  "ps" string        =>     "$(sys.fqhost)";
  "ps" string          =>     "domain.com";
  "ps" string    =>     "ipv4";
  "parameter_name" slist         =>     getindices("ps");

delete_lines:

  "$(parameter_name).*";

insert_lines:

  "$(parameter_name) = $(ps[$(parameter_name)])";
}


In most cases I don't really care about the final order of the lines in a file 
when I use this method.  (For files where order is important, like slapd.conf, 
I'll stick with a template or a long string.)

What bothers me is the apparent inconsistency of the function and the resulting 
(unnecessary) repair of the promise.

Does anyone else know what I'm talking about?  Have I missed any information 
saying that order is not guaranteed when using getindices?

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to