Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3497

How do I use classes and vars from non default namespaces?

    XMLWordPrintable

    Details

      Description

      Sourced From: https://github.com/cfengine/core/pull/4400

      Variables and classes are not evaluated in mustache templates from namespaces other than default. For example, I have a policy file for creating autofs map file, which looks as follows:

      body file control
      {
      namespace => "autofs";
      }
      
      bundle agent autofs
      {
      vars:
      linux::
      "template" string => "$(default:sys.workdir)/inputs/templates/ws/autofs.mustache";
      "hyperbeam_nodes" slist => expandrange("hyper[001-020]", 1);
      classes:
      linux::
      "hyperbeam_workstation" expression => "alm_test";
      
      ...
      files:
      linux::
      "/etc/autofs.map"
      create => "true",
      perms => set_perms("0644"),
      edit_template => "$(template)",
      handle => "restart_autofs",
      template_method => "mustache";
      }
      

      And the template file autofs.mustache:

      {{#classes.hyperbeam_workstation}}
      {{#vars.autofs:autofs.hyperbeam_nodes}}
      {{.}}
      {{/vars.autofs:autofs.hyperbeam_nodes}}
      {{/classes.hyperbeam_workstation}}
      

      So the class hyperbeam is not triggered form the namespace autofs when cf-agent is running. The variable hyperbeam_nodes is also not expanding from autofs namespace, using the syntax vars.autofs:autofs.hyperbeam_nodes.

      I have read the Cfengine documentation and did not find anything about accessing variables and classes from different namespases in mustache templates.

        Attachments

          Activity

            People

            • Assignee:
              a10042 Nick Anderson
              Reporter:
              a10042 Nick Anderson
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Summary Panel