Ask Your Question
1

Hi, I am new to puppet. Please can you tell me how to write a puppet module to replace any line of any file with a given line?

asked 2013-07-07 09:13:03 -0500

atul86244 gravatar image

Hi, I am new to puppet. Please can you tell me how to write a puppet module to replace any line of any file with a given line?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-07-07 13:14:50 -0500

Ancillas gravatar image

I'm short on time, so forgive what I consider to be an incomplete answer.

First off, managing single lines of files has turned out to be a Puppet anti-pattern. It's better to manage whole files.

That being said, here are two options. As I said, I'm short on time, so I'll post some links with the intention of following up later.

1.) Use the concat module

The concat module lets you build a file in chunks.

2.) Use an Augeas lense.

I've never used Augeas, but my understanding is that it allows you to find ... (more)

edit flag offensive delete link more

Comments

1

Hi, Thanks for this, I read about Augeas and I can workout how to replace a given line of a given file with a new line, but I want to ...(more)

atul86244 gravatar imageatul86244 ( 2013-07-08 09:23:47 -0500 )edit

That's a bit too general. How do you want to identify a line to change? By number? By regex? By parameter name?

Ancillas gravatar imageAncillas ( 2013-07-08 11:32:15 -0500 )edit

Lets assume it's by regex.

atul86244 gravatar imageatul86244 ( 2013-07-08 13:48:29 -0500 )edit
1

Then you're back to using Augeas. http://www.craigdunn.org/2011/06/configuring-tomcat-properties-files-with-augeas-and-puppet/. I don't know of anything more generic. If you want a resource where you specify ...(more)

Ancillas gravatar imageAncillas ( 2013-07-08 18:05:08 -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

Stats

Asked: 2013-07-07 09:13:03 -0500

Seen: 291 times

Last updated: Jul 07 '13