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

Function to_yaml in erb templates creates one additional indent

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Normal
    • Resolution: Duplicate
    • PUP 3.6.2
    • None
    • None

    Description

      If you have the following statement in your erb template:

      <%= {"key1"=>"value1", "key2"=>"value2"}.to_yaml %>
      

      The output produced by Puppet is (Please note the indents on each line of the "data" block):

      ---
        key1: value1
        key2: value2
      

      But it should be:

      ---
      key1: value1
      key2: value2
      

      irb creates the expected output. A quick and ugly fix is:

      <%= {"key1"=>"value1", "key2"=>"value2"}.to_yaml.gsub(/^\s{2}/, '') %>
      

      This command removes the additional indents, but this approach is not a feasible solution.

      Please fix the issue. It was first discussed here:
      http://stackoverflow.com/questions/25404774/unexpected-indent-in-puppets-erb-template-output

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Herr-Herner Jens Offenbach
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Zendesk Support