Ask Your Question

file_line match malfunction

asked 2017-09-07 01:41:56 -0600

vjsaisha gravatar image

While checking the function of file_line as per the puppet document example is not working it's appending not replacing. Code as follows

file_line { 'bashrc_proxy':
  ensure            => present,
  path              => '/tmp/file_line',
  line              => 'export HTTP_PROXY=http://squid.puppetlabs.vm:3128',
  match             => '^export\=',
  replace           => true,
edit retag flag offensive close merge delete



Please check out, whether a question's already been asked, before posting a new one. This one appears to have already been noted:

Kai Burghardt gravatar imageKai Burghardt ( 2017-09-07 18:15:20 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-07 12:22:03 -0600

notwithoutcid gravatar image

Is this the doc you are looking at ?

Without seeing the contents of /tmp/file_line I can't say for sure, but I doubt that that the match resource will work. The stdlib docs say to use

match  => '^export\ HTTP_PROXY\=',

The "^" indicates the beginning of the line, so you'll need to match exactly or use wildcards such as

match => '^export.*\=',

Just play with it until you have the right balance of always finding the line without false positives or multiple lines. good luck.

edit flag offensive delete link more

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


Asked: 2017-09-07 01:41:56 -0600

Seen: 435 times

Last updated: Sep 07 '17