Hello, In the reference manual I found that array can be of type scalar or list, but I did not manage to use list iteration:
--8<---------------cut here---------------start------------->8---
body common control
{
bundlesequence => { "test" };
version => "0.0.2";
}
bundle agent test
{
vars:
any::
"array[key1]" slist => {"val1"};
"array[key2]" slist => {"val2.1", "val2.2"};
"array[key3]" slist => {"val3"};
"keys" slist => getindices("array");
commands:
"/bin/echo $(keys) "
args => "$(array[$(keys)])";
}
--8<---------------cut here---------------end--------------->8---
Results in:
--8<---------------cut here---------------start------------->8---
/usr/sbin/cf-agent -K
Q: ".../bin/echo key1 ": key1 $(array[key1])
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo key1
$(array[key1])"
I: Made in version '0.0.2' of '/home/dad/.cfagent/inputs/promises.cf' near line
23
Q: ".../bin/echo key2 ": key2 $(array[key2])
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo key2
$(array[key2])"
I: Made in version '0.0.2' of '/home/dad/.cfagent/inputs/promises.cf' near line
23
Q: ".../bin/echo key3 ": key3 $(array[key3])
I: Last 1 QUOTEed lines were generated by promiser "/bin/echo key3
$(array[key3])"
I: Made in version '0.0.2' of '/home/dad/.cfagent/inputs/promises.cf' near line
23
--8<---------------cut here---------------end--------------->8---
I found no example, in tutorial, reference manual, solution guide or
policy starter kit.
Any hints?
Thanks.
--
Daniel Dehennin
Récupérer ma clef GPG:
gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
pgpxk2PxosMBE.pgp
Description: PGP signature
_______________________________________________ Help-cfengine mailing list [email protected] https://cfengine.org/mailman/listinfo/help-cfengine
