Forum: CFEngine Help
Subject: Re: CFEngine Help: edit_template array variable expansion
Author: jremond
Link to topic: https://cfengine.com/forum/read.php?3,26062,26075#msg-26075
New version of my code test.cf :
body common control
{
bundlesequence => { "dhcp", };
}
bundle agent dhcp
{
vars:
any::
"name" string => "srv1";
"name" string => "srv2";
"ip" string => "192.168.0.1";
"ip" string => "192.168.0.2";
"hosts" slist => getindices("name");
files:
debian::
"/tmp/post.expand"
create => "true",
edit_template => "/tmp/template.example";
}
And /tmp/template.example contains :
[%CFEngine BEGIN %]
# BEGIN $(dhcp.hosts)
${dhcp.ip[ $(dhcp.hosts)]}
$(dhcp.name[$(dhcp.hosts) ])
# END
[%CFEngine END %]
The result file post.expand contains :
# BEGIN srv1
${dhcp.ip[ srv1]}
$(dhcp#name[$(dhcp.hosts) ])
# END
# BEGIN srv2
${dhcp.ip[ srv2]}
$(dhcp#name[$(dhcp.hosts) ])
# END
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine