Ask Your Question
0

Using file_line for modifying the file in windows

asked 2014-11-19 18:45:28 -0500

Renuka gravatar image

updated 2014-11-19 18:46:17 -0500

I have installed stdlib module on the windows agnet, and wrote below code in sample.pp file

file_line { 'change_content':
  path  => 'C://puppetlabs//Helloworld.txt',
  line  => 'Hello World!',
  match => '^Hello World! , Whats Up',
}

When I execute above code , getting below error

C:\Windows\system32>puppet apply C:\Puppet_scripts\sample.pp Notice: Compiled catalog for windows178.kana-test.com in environment production in 0.09 seconds

Error: Validation of > Fileline[changecontent] failed: When providing a 'match' parameter, the > value must be a regex that matches > against the value of your 'lin e' > parameter at > C:/Puppetscripts/exchange.pp:5 > Wrapped exception: When providing a > 'match' parameter, the value must be a regex that matches again st the value > of your 'line' parameter

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-11-23 10:58:09 -0500

nrvale0 gravatar image

updated 2014-11-24 10:58:49 -0500

$myotherstuff = 'some other text'

file_line { 'change_content':   
  path   => 'C://puppetlabs//HelloWorld.txt',
  line   => "Hello World! ${myotherstuff}",
  match  => '^Hello World!.*$',
}
edit flag offensive delete link more
0

answered 2014-11-21 03:49:12 -0500

jonn gravatar image

Yes - this issue has come up before.

The current implementation seems to have a pretty limited use case - it will only work if your "match" parameter matches against the line that you want to add or replace. So in this case, you're probably stuck with something like this:

file_line { 'change_content':
  path  => 'C://puppetlabs//Helloworld.txt',
  line  => 'Hello World!',
  match => '^Hello World!.*$',
}

If this doesn't work for you, then you might need to consider using a different tool for this particular job.

edit flag offensive delete link more

Comments

Validation error was rectified ,but line is not modifying.I want to add some words after HelloWorld, How should I do?

Renuka gravatar imageRenuka ( 2014-11-21 14:55:29 -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

Stats

Asked: 2014-11-19 18:45:28 -0500

Seen: 1,532 times

Last updated: Nov 24 '14