About | FAQ | Help
Ask Your Question
0

file_line simply not working

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

Mr_Sharma gravatar image

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

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
1

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

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

Comments

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 -0500 )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 -0500 )edit
0

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

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

Comments

1

Oh, you also need https://github.com/puppetlabs/puppetlabs-stdlib 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 -0500 )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

Stats

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

Seen: 436 times

Last updated: Jan 11