1

I have a Perl script that I pushed out to all my Puppet Linux clients. I have since edited my script, module/modulename/files/scripts/a_script script on the Puppet master, but the clients don't get the change because they have the file. Apparently it doesnt checksum or use modtime. What is the best practice to ensure the files are up to date wit the master version? Do I need to write checksum logic, or is there already built in functionality?

The code I used to initially push was:

file { '/sbin/a_script':
    ensure => present,
    mode => 744,
    owner => root,
    source => "puppet:///modulename/scripts/a_script"
}

Obviously deleting the file and having it pull it back is a hacky solution, I am hoping for something more eloquent.

UPDATE Puppet does checksum and sync files in the puppet:/// filebucket on next run, I must have had an error that caused the file declaration to not be run. When I moved the declaration to site.pp it did sync the changes to the already existing files on clients.

  • By default Puppet does push changes to clients (checksum => md5, is set by default on the file type). So your problem must be something else. Hard to say without the actual code. – faker Apr 11 '14 at 17:12
  • You are right @faker. Can you not put a code block like the one in my example within the default node definition? – usedTobeaMember Apr 12 '14 at 1:09
  • I'm not sure, I don't use node definitions like that. In any case, the default node definition will only be used if there is no specific node definition found. – faker Apr 12 '14 at 11:05
0

I would suggest serving your scripts out of a flat directory structure, e.g. puppet:///modulename/a_script instead of puppet:///modulename/scripts/a_script

But if that's not an option, this sounds like a use case for the recurse directive. Without it, the default action seems to only ensure that your file is present, without regard to content.

Also check out the Puppet File Type Reference.

-- Edit --

I thought you were trying to sync a directory of scripts.

For your case, Puppet defaults to replace => true on a File type if the source checksum changes.

What's your output from puppet agent -t (or puppet agent --debug -t) on the client systems?

| improve this answer | |
  • What difference does the intermediate scripts directory make in context to this issue? – usedTobeaMember Apr 11 '14 at 16:17
  • @usedTobeaMember See edit. – ewwhite Apr 11 '14 at 17:12
  • I think my problem was somewhere else, it seems you're right about it checksumming. I had a problem when I had this file{} code block in my default {} node, but it worked when I moved it into site.pp (which also imports my nodes.pp). Can I not put a resource declaration in the default node block? Does it only allow me to include classes there? Or did I just probably have some error that I didnt catch, which got fixed when I moved it to site.pp? – usedTobeaMember Apr 11 '14 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.