Forum: CFEngine Help Subject: Re: Methods and default variables Author: neilhwatson Link to topic: https://cfengine.com/forum/read.php?3,23009,23050#msg-23050
Actually I want to apply this to template files so the number for arguments is know. I do like your idea though. Here is what I did get work work. I don't like it because it produces warnings. Suggestions welcome. bundle agent motd_tmp_44(motd_tmp, manager, phone, email) { vars: "tmpfile" string => "/var/tmp/cf_templates/motd", handle => "motd_tmp_44_vars_tmpfile", comment => "Location of template file on client."; no_motd_tmp:: "motd_tmp" string => "/var/cfengine/masterfiles/my_motd_tmp"; no_manager:: "manager" string => "John Smith"; no_phone:: "phone" string => "555-555-1234"; no_email:: "email" string => "jsm...@example.com"; classes: "no_motd_tmp" not => isvariable("motd_tmp"); "no_manager" not => isvariable("manager"); "no_phone" not => isvariable("phone"); "no_email" not => isvariable("email"); files: "$(tmpfile)" handle => "motd_tmp_44_files_tmp_cf_templates_motd", comment => "Copy motd template file", copy_from => local_cp("$(motd_tmp)"); "/etc/demo_motd" handle => "motd_tmp_44_files_etc_demo_motd", comment => "Expand motd file from template", perms => mog("0644","root","root"), create => "true", edit_defaults => empty, edit_line => expand_template("$(tmpfile)"); } However, that does create a lot of warnings when it is run: # cf-agent -IKf ./promises.cf Scalar variable motd_tmp_44.motd_tmp contains itself (non-convergent): $(motd_tmp) Scalar variable motd_tmp_44.manager contains itself (non-convergent): $(manager) Scalar variable motd_tmp_44.phone contains itself (non-convergent): $(phone) Scalar variable motd_tmp_44.email contains itself (non-convergent): $(email) _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine