Ask Your Question

When the Puppetmaster receives a specific file, how can you get it to upload it everytime to my windows hosts and overwrite the existing file.

asked 2015-10-02 05:17:33 -0500

michaelokoluko gravatar image

updated 2015-10-02 05:20:23 -0500

Basically we randomly have to push a windows build file (45Mb in size - might require zipping but not terribley important for now...) to the Puppetmaster which in turn should be clever enogh to upload it to all my windows hosts and overwrite the existing file on each host or shall we say the deprcared one

Does this invole the following?

  1. Some sort of crontab/crond/cronjob
  2. Mcollective - orchestration
  3. Manifest
  4. Invoke resource
  5. Ctime
  6. Mtime
  7. Batchfile
  8. PSCP
  9. Or ruby script - which I have very limited knowledge on.

Thanks Michael

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2015-10-02 10:15:04 -0500

GregLarkin gravatar image

All you have to do is use a standard file resource in your manifest like so:

file { 'C:/where/shall/I/put/the/file/':
  ensure => file,
  source => 'puppet:///modules/builder/,

Every time changes on the master, it will be pushed out to the agent that receives a catalog with the resource above. Puppet uses checksums to determine if the remote file has changed vs. the source file, but you can control that with the file resource's checksum attribute if needed.

Here are some more things to look out for on the Windows platform:

edit flag offensive delete link more


Many Thanks Greg! I got round that by using " checksum => 'mtime' " which leaves another problem - unziping the file after uploading it to the windows host? Apparently powershell doesn't recognize "unzip" or the use of "7-Zip" as a cmdlet or operable function - posting my code in the comment..

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-02 11:06:49 -0500 )edit

exec {'unzip_c:\\puppetfolder\': command => 'unzip -p c:\\puppetfolder\\', logoutput => true, provider => windows

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-02 11:14:19 -0500 )edit

Hmm, I have almost zero experience using Puppet on Windows and 0% experience with Powershell. This is might a good candidate for posting as a new question to see if it can attract some Windows experts.

GregLarkin gravatar imageGregLarkin ( 2015-10-06 01:50:47 -0500 )edit

Thanks Greg - I used the below code and it works !!! file { 'C:\\puppetfolder\\': ensure => 'file', source => 'puppet:///modules/downloadscript/', checksum => 'mtime', mode => '0775', owner => 'Administrator', group => 'Administrator',

michaelokoluko gravatar imagemichaelokoluko ( 2015-10-06 04:12:27 -0500 )edit

answered 2015-10-06 04:15:12 -0500

michaelokoluko gravatar image

Thanks Greg - I used the below code and it works !!!

file { 'C:\puppetfolder\':

ensure   => 'file',
source   => 'puppet:///modules/downloadscript/',
checksum => 'mtime',
mode     => '0775',
owner    => 'Administrator',
group    => 'Administrator',
edit flag offensive delete link more


Good to hear it!

GregLarkin gravatar imageGregLarkin ( 2015-10-14 16:48:17 -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


Asked: 2015-10-02 05:17:33 -0500

Seen: 114 times

Last updated: Oct 06 '15