Forum: CFEngine Help
Subject: Re: CFEngine Help: edit_template array variable expansion
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,26062,26077#msg-26077
I'd say there is a bug in the code or the documentation. I get the same
results.
neil@ettin ~/.cfagent/inputs $ cat tmpl.cf
body common control {
bundlesequence => {
"main",
};
inputs => {
"cfengine_stdlib.cf",
};
}
bundle common def {
vars:
"domain" string => "example.com";
}
bundle agent main {
methods:
"any" usebundle => dhcp;
}
bundle agent dhcp {
vars:
"name" string => "srv1";
"name" string => "srv2";
"mac" string => "52:54:00:00:00:00";
"mac" string => "52:54:00:00:00:01";
"ip" string => "192.168.0.1";
"ip" string => "192.168.0.2";
"hosts" slist => getindices("name");
files:
"/home/neil/tmp/hosts"
handle => "update_dhcp_hosts_conf",
comment => "Update the hosts list for dhcp config",
create => "true",
edit_template => "/home/neil/tmp/hosts.tmp";
reports:
cfengine::
"name => $(name[$(hosts)])";
"name => $(mac[$(hosts)])";
"name => $(ip[$(hosts)])";
}
neil@ettin ~/.cfagent/inputs $ cf-agent -IKf ./tmpl.cf
-> Edited file /home/neil/tmp/hosts
R: name => srv1
R: name => srv2
R: name => 52:54:00:00:00:00
R: name => 52:54:00:00:00:01
R: name => 192.168.0.1
R: name => 192.168.0.2
neil@ettin ~/.cfagent/inputs $ cat /home/neil/tmp/hosts
# 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