Forum: CFEngine Help Subject: Re: Using Variables in insert lines Author: sauer Link to topic: https://cfengine.com/forum/read.php?3,24417,24531#msg-24531
zzamboni Wrote: ------------------------------------------------------- > It shouldn't be too hard to make a version > of set_config_values() that takes arrays and makes > one line per value in the array. Maybe I'll take a > stab at it when I have some time. Wouldn't that just be the "append_if_no_lines" bundle, called with a "lines" slist generated by something like this: "temp_key_list" slist => getindices("config_array"); "temp_line_arr[$(temp_key_list) $(config_array[$(temp_key_list)])]" string => "1"; "lines" slist => getindices("temp_line_arr"), policy => "free"; (the lines slist definition is "free" because warnings about reassignment are generated otherwise. Seemingly the recursion-limited variable dependency resolver dealie (which is what that procedure should be called if it's not already :)) doesn't catch the fairly deep recursive dependency there. Moving @lines to a separate bundle which takes temp_line_arr as a parameter would resolve that issue as well, but there's no reason to not just make it a free variable, as the end result of inserting lines won't be adversely impacted by getting called with a null list in the first iteration. BTW, it seems like it'd be handy if we could use handle and depends{} attributes on variables to provide hints to the agent (etc.) about resolving variable interdependency when cf-promises can't. Maybe? _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine