Ask Your Question

file_line simply not working

asked 2017-06-06 05:03:22 -0600

rajeevsharma gravatar image

updated 2017-06-06 08:19:56 -0600

DarylW gravatar image

Hi, I am using file_line resource to match and replace but it's simply not working. I have tried with even simpler code but it simply ignoring my file_line resource.

file { '/tmp/eureka.txt':
  ensure => present,
file_line { 'Append a line to /tmp/eureka.txt':
  ensure => 'present',
  path => '/tmp/eureka.txt',
  line => 'Hello World',

I have already added "name": "puppetlabs-stdlib", "version": "4.17.0" and using PE 2015.2. After executing the above code I don't see any change happening except creation of the eureka file. Any idea?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2017-06-13 13:42:50 -0600

DevOpsProDude gravatar image

Other than some formatting issues, I don't see why that's not working, however, you can also try:

  file { '/tmp/eureka.txt':
    ensure => file,

  file_line { 'Append a line to /tmp/eureka.txt':
    ensure  => present,
    path    => '/tmp/eureka.txt',
    line    => 'Hello World',
    require => File['/tmp/eureka.txt'],
edit flag offensive delete link more



Oh, you also need module to be in your module path in order for file_line to work. Hopefully, you are familiar with Puppet Code Manager and using Puppetfile.

DevOpsProDude gravatar imageDevOpsProDude ( 2017-06-13 13:44:29 -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

1 follower


Asked: 2017-06-06 05:03:22 -0600

Seen: 130 times

Last updated: Jun 13