Ask Your Question

PUP-927: any workaround?

asked 2014-10-29 08:41:43 -0500

Pierrick gravatar image

I am facing this issue:

Is there a known way of working around it? For example, I am doing the following (on Windows):

file { 'C:\sql2014install.ini': content => template('mssql2014/config.ini.erb'), }

The mssql2014/config.ini.erb file has CRLF line endings. The output C:\sql2014install.ini always has LF line endings and therefore the MSSQL 2014 install does not see the line endings.

Does anyone know a workaround? Should I do a simple file copy instead?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2014-10-29 23:28:43 -0500

cbarbour gravatar image

updated 2014-10-29 23:28:56 -0500

You can use the regsubst function to fix the newlines after processing the template.

The following example should do the trick, and it shouldn't break your code once Puppet releases a fix for this problem, because it correctly checks for '\r\n' before substitution.

class test {
  file { 'C:/vagrant/test.txt':
    ensure => 'file',
    content => regsubst(template('test/test.txt.erb'), '(?<!\r)\n', "\r\n", 'G')
edit flag offensive delete link more


Thank you. I did not know you could use regsubst directly inside a template. I previously used it in a separate ruby file.

Pierrick gravatar imagePierrick ( 2014-10-30 03:30:13 -0500 )edit

No problem. In this case, it's actually a Puppet function that can be used inside a Puppet manifest. This works because the bug your encountering is in the ERB rendering code. If you used it in your template, you'd encounter the original bug again. :)

cbarbour gravatar imagecbarbour ( 2014-10-30 12:24:23 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2014-10-29 08:41:43 -0500

Seen: 206 times

Last updated: Oct 29 '14