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

incorrect behavior in expand_template in version 3.4.1

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: To Do
    • Priority: Low
    • Resolution: Unresolved
    • Affects Version/s: 3.4.1, 3.13.0
    • Fix Version/s: None
    • Component/s: Promise type: files
    • Labels:

      Description

      Hello,

      In version 3.4.1 expand_template behaves wrong compare to version 3.3.5 when reading from file
      "testvar" string => readfile("/etc/hosts",10000);

      It inserts beginning of the variable into the correct place in the file, but the rest of the variable in the beginning of the file.
      it breaks all my promises which use expand_template.

      Here is the example of the promise:

      body common control {
       bundlesequence => { "test" };
       inputs => { "cfengine_stdlib.cf"}; 
      }
      
      bundle agent test 
      {
      vars:
      	"testvar"		string => readfile("/etc/hosts",10000);
      
      files:
      	"/tmp/myfile"
      	create => "true",
      	perms => m("644"),
      	edit_defaults => empty,
      	edit_line => expand_template("/tmp/mytemplate");
      }
      

      Here is the template I used:

      This is the beginning of the file
      ########################
      Including CFengine var, that was read from the file
      
      $(test.testvar)
      ########################
      This is the end of the file.
      

      Here is the /etc/hosts:

      127.0.0.1	localhost.localdomain	localhost
      ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
      

      Expected result ( and it works in 3.3.5):

      This is the beginning of the file
      ########################
      Including CFengine var, that was read from the file
      
      127.0.0.1	localhost.localdomain	localhost
      ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
      ########################
      This is the end of the file.
      

      Result in version 3.4.1

      This is the beginning of the file
      ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
      
      ########################
      Including CFengine var, that was read from the file
      
      127.0.0.1	localhost.localdomain	localhost
      ########################
      This is the end of the file.
      

      As you can see it puts first line from testvar in correct place, but second line in the beginning of the file.

      it breaks all promises that use expand_template and generate incorrect config files out of templates.
      I had to roll back to 3.3.5

      Thanks,
      Vlad.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              vlads2013 Vlad Seagal
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel