Ask Your Question

files copy

asked 2013-12-06 15:44:16 -0500

mandm_zoom gravatar image

updated 2013-12-06 20:08:20 -0500

Stefan gravatar image

i am trying to copy some pem files from one master to agent, but i notice that the pem file does not get copied if the file timestamp has updated, it only gets copied when the file is modified and the file size changes..

here is my module init.pp

class copypemdev {
  # download the pem file
  file { "/tmp/pems" :
    ensure  => directory,
    source  => "puppet:///modules/copypemdev/pems",
    recurse => true,
    owner   => "abc",
    group   => "abc",
    backup  => false,
    notify  => Exec["copy pem"],

  # copy the pem file to the desired location
  exec { "copy pem":
    command     => "/bin/cp -rp /tmp/pems/* /var/www/",
    subscribe   => File["/tmp ...
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-12-06 20:16:03 -0500

Stefan gravatar image

The algorithm that is used to determine whether a file needs to be replaced depends on the checksum parameter of the file resource (see doc). The default value is md5sum which does only take the content into account (in general this is what you want).

If you want to copy the file when the modification time changes you can explicitly set checksum => mtime (I guess this was only added as a performance considerations as checksumming a large directory tree can be painful). You cannot do both md5sum AND mtime.

Why do you want to replace a file if the content ... (more)

edit flag offensive delete link more


Thanks guys for the reply

mandm_zoom gravatar imagemandm_zoom ( 2013-12-06 21:46:36 -0500 )edit

The reason i wanted to copy the file even when the content is same, is say a pem file was created while testing and a wrong password was used to ...(more)

mandm_zoom gravatar imagemandm_zoom ( 2013-12-06 21:48:13 -0500 )edit

answered 2013-12-06 18:11:05 -0500

lavaman gravatar image

Puppet checksums files it serves and the copies it puts on agents. It uses these checksums to determine if the file has changed. Checksums are based on the contents of the file, and does not take into account modification time.

edit flag offensive delete link more

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: 2013-12-06 15:44:16 -0500

Seen: 404 times

Last updated: Dec 06 '13