Puppet string manipulation failed


Not sure what is wrong with the below configuration

sh-4.2# cat /etc/puppetlabs/code/environments/production/manifests/demo.pp
node stapp03.stratos.xfusioncorp.com {
  file_line { 'replace line':    path => '/opt/devops/demo.txt',
    line => 'Welcome to xFusionCorp Industries!',
    match   => "Welcome to Nautilus Industries!",

The line looks replaced as I took a backup first just in case

[banner@stapp03 ~]$ diff demo.txt /opt/devops/demo.txt
< Welcome to Nautilus Industries!
> Welcome to xFusionCorp Industries!
[banner@stapp03 ~]$  

yeah, unfortunately I didn’t save the question as it doesn’t show it anymore once the task is failed, but I’m almost sure that the data in there is correct.

Here’s the failed message

Something is wrong with demo.pp as /opt/devops/demo.txt file does not contain correct data on App Server 3

@wael.sadek This is marked Success for you.

@Inderpreet , wow , thanks a lot for your fast response !!

your solution is wrong and actually misleading others, in fact you have wrongly configured your lines
line => ‘Welcome to xFusionCorp Industries!’,
match => “Welcome to Nautilus Industries!”,

these two should be exactly different.

file_line { 'replace':
    path      => $line::path_to_conf,
    replace => true,
    line       => $line::new_line_to_use,
    match  => $line::exact_match_for_old_line


Not sure what you mean, I got it from the puppet documentation :

Could you please explain ?

@wael.sadek the questions says replace
Welcome to Nautilus Industries!
Welcome to xFusionCorp Industries!

so the correct config is:
line => Welcome to xFusionCorp Industries!,
match => Welcome to Nautilus Industries!,

while your config is exactly opposite. so obviously you wont get a desired result.


No, please check the diff output the old file differs from the new one.
Your task may be different than mine it doesn’t have to be the same.