Ask Your Question
0

template or files for Windows node

asked 2013-10-02 08:07:10 -0600

Quindoo gravatar image

How can you copy a file from templates or files to a Windows node without screwing up the structure of the file.

I am working on a puppet module about updating puppet itself. I get stuck on the part for enrolling the puppet.conf on Windows because it doesn't include the newline or carriagereturns from the template or file.

I tried with \n or \r or even \r\n but it just adds that as passive text.

This is the text:

class puppet::config {

include puppet::params

        case $operatingsystem {
                centos: {
                        file { "/etc/puppet/puppet.conf" :
                                ensure => present,
                                content => template ...
(more)
edit retag flag offensive close merge delete

Comments

Do you mean that you converted your puppet.conf.erb to Windows-style line endings, and it still didn't work? Also, what do you mean by "passive text"?

GregLarkin gravatar imageGregLarkin ( 2013-10-02 12:20:56 -0600 )edit

How do you convert it? I added the \n and \r in the text but it results in just text. for example: [main] server=servername\npluginsync=true\n[agent]

Quindoo gravatar imageQuindoo ( 2013-10-02 13:26:42 -0600 )edit

This page has a number of suggestions: http://kb.iu.edu/data/acux.html. Personally, I use the unix2dos/dos2unix tools on my UNIX systems.

GregLarkin gravatar imageGregLarkin ( 2013-10-02 13:30:08 -0600 )edit

Thanks, that worked!

Quindoo gravatar imageQuindoo ( 2013-10-03 01:57:25 -0600 )edit

Good to hear! I just added an answer if you wouldn't mind marking it as correct when you have a moment - thank you!

GregLarkin gravatar imageGregLarkin ( 2013-10-03 11:17:23 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-10-03 11:19:37 -0600

GregLarkin gravatar image

In order to install a file on a Windows machine, make sure that it contains the proper line endings for that platform. If you use a file with UNIX line endings and install it on a Windows machine, the lines will run together.

There are a variety of ways to convert back and forth between Windows and UNIX line endings. This page has a number of suggestions: http://kb.iu.edu/data/acux.html . Personally, I use the unix2dos/dos2unix tools on my UNIX systems.

edit flag offensive delete link more
1

answered 2013-10-07 12:39:36 -0600

Ben B gravatar image

Seems the suggestion here is to convert/correct the output using external tools after you created an incorrect file. Each to their own but would it not be better to create the file correctly in the first place rather than having the additional step of fixing what you did wrong.

I had the same issue recently (using an windows generated template) and puppet spitting out a unix line ended file.

The problem lies (for me at least) in: content => template("MyModule/MyTemplate.erb")

I simply replaced that with: content => regsubst(template("ordermanager/web.config.erb"), '\n', "\r\n", 'EMG')

which ... (more)

edit flag offensive delete link more

Comments

This is the right answer with dos2unix you need it after every provision step. When you use vagrant with a shared drive on a windows host. In that case you need to do this content => regsubst(template('orautils/wls/stopNodeManager.sh.erb'), '\r\n', "\n", 'EMG') template function should fix this

Edwin gravatar imageEdwin ( 2014-10-26 14:22:25 -0600 )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

Stats

Asked: 2013-10-02 08:07:10 -0600

Seen: 1,354 times

Last updated: Oct 07 '13