Ask Your Question

file_line simply not working

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

Mr_Sharma 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

2 Answers

Sort by ยป oldest newest most voted

answered 2018-01-11 07:01:38 -0600

Mr_Sharma gravatar image

Hi Guys, I couldn't find the solution then and recently I got stuck with the same problem again. However there is no problem with the file_line code, the problem is with supportive library.

I had the puppetlabls-stdlib already installed in my module path but somehow it wasn't working, this is why?

puppet module list

this command told me what are the modules which are dependent on stdlib module (a command to just inspect).

The module what I installed was mistakenly downloaded as puppetlab-stdlib (with missing 's') and this is why file_line wasn't able to use the module's library. I renamed puppetlab-stdlib to stdlib only and everything started working as charm.

edit flag offensive delete link more


how did you install the module? did you `puppet module install` it, use r10k/puppet-librarian? manually pull it down into the directory? It should only be named 'stdlib' within your modulepath

DarylW gravatar imageDarylW ( 2018-01-11 08:22:05 -0600 )edit

yes right. I used `puppet module install puppetlab-stdlib` so I guess it got downloaded in a directory with incorrect name and hence got unreachable.

Mr_Sharma gravatar imageMr_Sharma ( 2018-01-11 10:36:05 -0600 )edit

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: 716 times

Last updated: Jan 11