Hi,
I'm starting out with CFEngine by trying to replace a load of python
managing a few services. I'm having issues trying using the template
system to right the configs, mainly because I can't see how to the
current value of an iteration in order to populate the template.
Here's a minimal example of what I'm trying to do:
------------------8<----------------------------------------
body common control
{
version => "0.1";
bundlesequence => { "service1" };
inputs => { "cfengine_stdlib.cf" };
}
bundle common g
{
vars:
# Keeping in common as they be used in multiple services
# split out into bundles
"configs" slist => {
"test1",
"test2"
};
"config_ipv4[test1]" string => "192.0.2.1";
"config_ipv4[test2]" string => "192.0.2.1";
}
bundle agent service1
{
vars:
"configs" slist => {@(g.configs)};
"config_ipv4" slist => {@(g.config_ipv4)};
"config_template" string => "
var1=$(configs)
var2=$(config_ipv4.configs)
";
files:
"/tmp/$(configs)"
comment => "Create the config from template",
create => "true",
edit_line => append_if_no_line("$(config_template)");
------------------8<----------------------------------------
The out of both /tmp/test1 and /tmp/test2 ends up as:
------------------8<----------------------------------------
var1=test2
var2=$(config_ipv4.configs)
------------------8<----------------------------------------
I am giving the warnings in cf-promises and cf-agent about "!!
Redefinition of variable "config_template" (embedded list in RHS) in
context "service1"" and I do understand why I'm getting the output.
However, what I can't figure out if there's a way of getting the current
value of "configs" as the agent is iterating through it.
Is this possible, or am I going about things the wrong way?
Thanks,
Niall.
--
The virus contained in this message was not detected.
http://niall.donegan.tel
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine