Ask Your Question

Trying to use file_line to replace line in file

asked 2016-11-30 16:28:31 -0600

Nizen gravatar image

updated 2016-11-30 18:24:29 -0600

lupin gravatar image

I see a lot about file_line on the forum, but I'm not finding an answer to an issue I'm having. I am trying to replace exact matches with another line. For example:

class line::conf {
  file { $line::path_to_conf :
    ensure => present,
    } -> 
  file_line { 'replace':
    path      => $line::path_to_conf,
    replace => true,
    line       => $line::new_line_to_use,
    match  => $line::exact_match_for_old_line

Everything I'm reading says this should work. I've tried regex, but still nothing. It just appends $line::newlineto_use to the end of the config.

I've been trying to write two modules to manage two separate configs, and at this point I'm just about to throw things out windows. :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-11-30 18:26:15 -0600

lupin gravatar image

updated 2016-12-01 11:35:52 -0600

I've added the replace => true parameter . Take note the match value should match exactly regex-wise to what you want to replace with value of line.

edit flag offensive delete link more


Works. Thanks!

Nizen gravatar imageNizen ( 2016-12-01 10:40:40 -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


Asked: 2016-11-30 16:28:31 -0600

Seen: 3,631 times

Last updated: Dec 01 '16