Forum: CFEngine Help
Subject: Template expansion with lists
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,23033,23033#msg-23033

It is possible to have a list expanded in a template?  My attempts so far have 
meet with failure:

# cat promises.cf
body common control {

        bundlesequence => {
                "main",
        };

        inputs => {
                "cfengine_stdlib.cf",
        };
        host_licenses_paid => "50";
}

bundle agent main {

        vars:

                "time_servers" slist => {
                        "tick.example.com",
                        "tock.example.com",
                        "clock.example.com"
                };
                "other" string => "Other config option";

        methods:

                "any" usebundle => ntp_tmp_1("@(main.time_servers)","$(other)"),
                handle => "main_methods_ntp_tmp_1",
                comment => "call motd_tmp_44 bundle";
}

bundle agent ntp_tmp_1 (server, other){

        vars:

                "tmpfile" string => "/var/tmp/cf_templates/ntp.conf";

        files:

                "/etc/demo_ntp.conf"
                        perms => mog("0644","root","root"),
                        create => "true",
                        edit_defaults => empty,
                        edit_line => expand_template("$(tmpfile)");

        reports:

                cfengine_3::
                        "Server: $(server)";
}

# cat /var/tmp/cf_templates/ntp.conf
@{ntp_tmp_1.server}
@{server}
${server}
${ntp_tmp_1.server}
${ntp_tmp_1.other}

# cf-agent -IKf ./promises.cf
 !! Unknown user $(user) in promise
R: Server: tick.example.com
R: Server: tock.example.com
R: Server: clock.example.com

# cat /etc/demo_ntp.conf
@{ntp_tmp_1.server}
@{server}
${server}
${ntp_tmp_1.server}
Other config option


I had hoped to see some attempt at expansion for the slist called server.  Is 
this even possible?

_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to