Uploaded image for project: 'Puppet'
  1. Puppet
  2. PUP-927

puppet apply on Windows always uses *nix style newlines from templates

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Done
    • None
    • PUP 3.8.0, PUP 4.1.0
    • Windows
    • Windows Server 2008 R2 64-bit, Windows Server 2003 SP2 32-bit, Puppet Enterprise 3.1.0

    • 1
    • Windows 2015-02-11, Windows 2015-02-25, Windows 2015-03-11, Windows 2015-03-25, Windows 2015-04-08
    • Bug Fix

    Description

      When applying manifests containing templates using 'puppet apply' on Windows, the Windows-style CRLF line ending is always replaced with *nix style LF. The behavior is the same whether the template originally contains Windows line endings or *nix line endings - the generated file always has *nix line endings.

      This does not occur if the template is generated on a Linux master from an erb containing Windows-style line endings (the correct Windows style endings are preserved). Also, very strangely, Windows-style newlines are preserved with 'puppet apply' when run on Linux.

      C:\>puppet agent -t
      Info: Retrieving plugin
      <...snip...>
      Info: Caching catalog for server2008r2a
      Info: Applying configuration version '1386132854'
      Notice: /Stage[main]//Node[default]/File[c:/newline_test.txt]/content:
       
      Info: /Stage[main]//Node[default]/File[c:/newline_test.txt]: Filebucketed c:/new
      line_test.txt to main with sum 72cff61ef2581d7e849e2fa4c20b4e31
      Notice: /Stage[main]//Node[default]/File[c:/newline_test.txt]/content: content c
      hanged '{md5}72cff61ef2581d7e849e2fa4c20b4e31' to '{md5}ba4749398421eb02703fc958
      71fdd73e'
      Notice: Finished catalog run in 0.95 second
       
      C:\>hexdump.exe newline_test.txt
      00000000: 74 65 73 74 0D 0A 74 65 - 73 74 0D 0A 74 65 73 74 |test  test  test|
      00000010: 0D 0A 74 65 73 74 0D 0A - 74 65 73 74 0D 0A 74 65 |  test  test  te|
      00000020: 73 74 0D 0A 0D 0A       -                         |st    |
      00000026;
       
      C:\>hexdump.exe newline_test.txt.erb
      00000000: 74 65 73 74 0D 0A 74 65 - 73 74 0D 0A 74 65 73 74 |test  test  test|
      00000010: 0D 0A 74 65 73 74 0D 0A - 74 65 73 74 0D 0A 74 65 |  test  test  te|
      00000020: 73 74 0D 0A 0D 0A       -                         |st    |
      00000026;
       
      C:\>type test.pp
      file { 'c:/newline_test.txt':
        ensure  => file,
        content => template('c:/newline_test.txt.erb'),
      }
      C:\>puppet apply test.pp 
      Notice: Compiled catalog for server2008r2a in environment production in 0.09 sec
      onds
      Notice: /Stage[main]//File[c:/newline_test.txt]/content: content changed '{md5}b
      a4749398421eb02703fc95871fdd73e' to '{md5}72cff61ef2581d7e849e2fa4c20b4e31'
      Notice: Finished catalog run in 0.12 seconds
       
      C:\>hexdump.exe newline_test.txt
      00000000: 74 65 73 74 0A 74 65 73 - 74 0A 74 65 73 74 0A 74 |test test test t|
      00000010: 65 73 74 0A 74 65 73 74 - 0A 74 65 73 74 0A 0A    |est test test  |
      0000001f;
      

      Note that I have only tested this on Puppet Enterprise.

      Note: There may be other places this happens. Look for File.read and adjust.

      risk: high
      probability: high (almost any windows template use when testing with apply on a windows agent)
      severity: high (prevents template use with certain resources)
      test layer: unit
      covered by unit tests. validate PR in windows and linux

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              james.sweeny James Sweeny
              Eric Thompson Eric Thompson
              Votes:
              1 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support