Ask Your Question
3

Why is Puppet trying to ensure present a file with date appended?

asked 2014-08-01 19:30:34 -0500

salientdigital gravatar image

I've got my systems almost completed in Puppetcode. I run puppet agent -t environment <branchname> --noop on an agent, and it gives no errors, so I peel off --noop and now get a bunch of similar errors:

Error: Could not set 'present' on ensure: No such file or directory - /path/to/file/filename.ext20140802-18682-wu50st.lock at 10:/etc/puppetlabs/puppet/environments/branchname/modulename/modulename/manifests/profile/myclass.pp

What's with the date and lock file appended to the name of the file I'm trying to ensure? Suggestions how to fix it would be most appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-08-02 14:03:27 -0500

Stefan gravatar image

updated 2014-08-02 14:04:05 -0500

If puppet has to replace a file (or create a file for that matter), it will first create a temporary file in the same directory and later rename the file to the desired name. This has two reasons:

  • a rename within the same filesystem is supposed to be atomic: So no program ever sees a half written file
  • puppet can validate the checksum of the temporary file and check if it is really the correct one. If the checksum does not match, puppet will trigger a warning and not replace the the original file.

So the question remains why you see the error. Is it possible that you ensure a file in a directory that is not yet present?

edit flag offensive delete link more

Comments

Since the agent is running with --noop, it's possible that the creation of the parent directory never actually happens, and the transfer of the temporary file therefore fails.

mapa3m gravatar imagemapa3m ( 2014-08-04 06:48:57 -0500 )edit

if you run with noop you'll not see the error, because no temporary file is written in this case. Puppet would just check the checksum of the original file (if present) against the desired checksum (if your file resource has a content attribute, the agent will generate the checksum of the value; if your file resource has a source attribute, puppet will ask the puppetmaster for the checksum of the desired content)

Stefan gravatar imageStefan ( 2014-08-04 12:45:23 -0500 )edit

Ah, good to know

mapa3m gravatar imagemapa3m ( 2014-08-04 13:07:02 -0500 )edit

Can it be disabled? I'm trying to write to `/sys` directory and temporary files don't seem to work there. This is what I'm trying to do: ``` file { '/sys/module/nfs/parameters/nfs4_disable_idmapping': content => "N\n", backup => false, } ```

Envek gravatar imageEnvek ( 2017-04-20 14:12:46 -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

2 followers

Stats

Asked: 2014-08-01 19:30:34 -0500

Seen: 2,924 times

Last updated: Aug 02 '14