Forum: CFEngine Help
Subject: Re: reasonable "list append" workaround?
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,23935,24011#msg-24011
Matt, your approach almost works. The problem is that for classes that are not
defined, the variable will not be expanded and you will get the literal string
'${backup_server}' (for example) in the list.
You can fix this and make the approach more general by making the variables
slist instead of string, and using policy => "ifdefined" in the assignment to
testfiles. Something like this:
body common control {
bundlesequence => { "test2" };
}
bundle agent test2
{
vars:
backup_server::
"backup_svr_file" slist => { "/tmp/test_backup_server",
"/tmp/test_backup_server2" };
dns_server::
"dns_svr_file" slist => { "/tmp/test_dns_server" };
utility_net::
"util_svr_file" slist => { "/tmp/test_utility_net" };
redserver::
"redserver_file" slist => { "/tmp/test_redserver" };
blueserver::
"blueserver_file" slist => { "/tmp/test_blueserver", "/tmp/blue2" };
any::
"testfiles" slist => {
"@{backup_svr_file}",
"@{dns_svr_file}",
"@{util_svr_file}",
"@{redserver_file}",
"@{blueserver_file}"
},
policy => "ifdefined";
reports:
cfengine::
"${testfiles}";
}
Neil, the meaning in your example is very clear, but I worry about the
explosion in states, since you have to express all the possible combinations of
classes in which you are interested.
Best regards,
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine