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

As a policy writer I would like to be able to directly use variables containing information about paths for the current policy run in body file control so that I can reduce the amount of boilerplate policy.

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Currently dynamic inputs can be implemented in body file control in two ways:

      1. Classes guarding different inputs containing explicit known paths in body file control. For example:
        body file control
        { 
          redhat::
        
            inputs => { "/var/cfengine/inputs/inventory/linux.cf", "/var/cfengine/inputs/inventory/redhat.cf" };
        
          debian::
        
            inputs => { "/var/cfengine/inputs/inventory/linux.cf", "/var/cfengine/inputs/inventory/debian.cf" };
        
          linux.!(redhat|debian)::
        
            inputs => { "/var/cfengine/inputs/inventory/linux.cf" };
        }
        

        This works fine, except that it complicates testing as you can not checkout policy to an arbitrary location and run the policy.

      2. Via a variable defined in a common bundle. For example:
        bundle common module_environments_file_control
        {
          vars:
              "inputs"
                slist => {
                           "$(this.promise_dirname)/environmentmodules/main.cf",
                           "$(this.promise_dirname)/Lmod/main.cf",
                         };
        }
        
        body file control
        {
          inputs => { @(module_environments_file_control.inputs) };
        }
        

        This is quite flexible as it allows for the construction of inputs based on external data, or various lists merged together under different conditions. It works well, except it necessitates a lot of boiler plate policy. At least 5 additional lines each time I want to include something via a relative path.

      It would be nice if I could reference variables containing path information for the current policy run directly from body file control for the common simple case. For example:

      body file control
      {
        inputs => {
                    "$(this.promise_dirname)/environmentmodules/main.cf",
                    "$(this.promise_dirname)/Lmod/main.cf",
                  };
      }
      

      Currently the above produces an error because $(this.promise_dirname) is not available in body file control.

      The variables that I think would be most useful for this are:

      • Full path to the policy entry directory
      • Full path to the current policy file (basically the same as $(this.policy_filename) so that you could load things like $(this.policy_filename).sub like we do in the test framework.
      • Full path to the current policy file directory (basically the same as $(this.policy_dirname)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                a10003 Eystein Maloy Stenberg
                Reporter:
                a10042 Nick Anderson
              • Votes:
                1 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel