Right - this would work fine. Still, it seems an odd omission to have no 
counterpart to the getindices() function. Is this intentional?

Thanks,
--Diego


From: Nicolas Charles [mailto:charl...@gmail.com]
Sent: Saturday, January 30, 2010 2:33 AM
To: Diego Zamboni
Cc: help-cfengine@cfengine.org
Subject: Re: How to get all the values of an array?

Hi,

Maybe you'd rather call the bundle backuping the file once per file ?


bundle agent array() {
 vars:
 "files[sysctlconf]" string => "/etc/sysctl.conf";
 "files[inittab]" string => "/etc/inittab";
 "files[sshdconfig]" string => "/etc/ssh/sshd_config";

 "filesId" slist => getindices("files");

 methods:
  "any" usebundle => myReports("$files[$(filesId)]");
}

bundle agent myReports(values) {
  reports:
   linux::
   "This is the file : $(values)";
}

On Fri, Jan 29, 2010 at 10:49 PM, Diego Zamboni 
<di...@zzamboni.org<mailto:di...@zzamboni.org>> wrote:
Hi,

Sorry for the possibly dense question, but how do I get a list
containing all the values of an associative array? I know the
getindices() function, but I can't find a similar getvalues() one.

My use case is that I have something like this:

 # Files to edit
 "files[sysctlconf]" string => "/etc/sysctl.conf";
 "files[inittab]" string => "/etc/inittab";
 "files[sshdconfig]" string => "/etc/ssh/sshd_config";

I would like to automatically get all the filenames in a list so I can
pass them to another bundle, for automatically doing backups before
making any changes.

Thanks,
--Diego
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org<mailto:Help-cfengine@cfengine.org>
https://cfengine.org/mailman/listinfo/help-cfengine

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

Reply via email to