Forum: CFEngine Help
Subject: edit_template array variable expansion
Author: jremond
Link to topic: https://cfengine.com/forum/read.php?3,26061,26061#msg-26061

Hi all

I am trying to use the new template feature and but I get some unwanted 
substitution 

bundle agent dhcp 
{
vars:

  any::
    "name"       string => "srv1";
    "name"    string => "srv2";

    "ip"         string => "192.168.0.1";
    "mac"        string => "52:54:00:00:00:00";

    "ip"      string => "192.168.0.2";
    "mac"     string => "52:54:00:00:00:01";

    "hosts"             slist  => getindices("name");
files:

  debian::

      "/tmp/hosts.example.expand"
      handle => "update_dhcp_hosts_conf",
      comment => "Update the hosts list for dhcp configuration",
      create => "true",
      edit_template => "/tmp/hosts.example";

}


and /tmp/hosts.example looks like

group {
        ddns-domainname "$(def.domain)";
        ddns-rev-domainname "in-addr.arpa";

[%CFEngine BEGIN %]
# BEGIN $(dhcp.hosts)
        host $(dhcp.name[$(dhcp.hosts)]) {
                hardware ethernet ${dhcp.mac[$(dhcp.hosts)]};
                fixed-address ${dhcp.ip[$(dhcp.hosts)]};
                option host-name "$(dhcp.name[$(dhcp.hosts)])";
                ddns-hostname "$(dhcp.name[$(dhcp.hosts)])";
        }
# END
[%CFEngine END %]
}


The result is (file hosts.example.expand) :

group {
        ddns-domainname "example.com";
        ddns-rev-domainname "in-addr.arpa";

# BEGIN srv1
        host $(dhcp#name[$(dhcp.hosts)]) {
                hardware ethernet ${dhcp#mac[$(dhcp.hosts)]};
                fixed-address ${dhcp#ip[$(dhcp.hosts)]};
                option host-name "$(dhcp#name[$(dhcp.hosts)])";
                ddns-hostname "$(dhcp#name[$(dhcp.hosts)])";
        }
# END
# BEGIN srv2
        host $(dhcp#name[$(dhcp.hosts)]) {
                hardware ethernet ${dhcp#mac[$(dhcp.hosts)]};
                fixed-address ${dhcp#ip[$(dhcp.hosts)]};
                option host-name "$(dhcp#name[$(dhcp.hosts)])";
                ddns-hostname "$(dhcp#name[$(dhcp.hosts)])";
        }
# END
}

Can anyone tell me why there are # ?
There is no difference between 3.3.1 and 3.3.2 on Debian amd64 server.

Jean

_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to