Recently I’ve been looking for ways of keeping a box up-to-date as far as git is concerned, and for windows the options are pretty limited. The vast majority of DevOps seem to like Puppet, so I decided to give it a try. The problem is windows isn’t very good without a few helper programs such as ssh, but we’ll get around that with Cygwin. The master box will be a Centos 6.4 x64 host.
The first thing we’ll need to do is install the EPEL and Puppet repositories with, then install the puppet software and start the master process:
1 2 3
Let’s go ahead and get some files prepared. Create a git repo in /opt called test with a file in it (test.txt), committed to master:
1 2 3 4 5 6 7
One last thing we’ll need for puppet to work with git is VCSRepo, so let’s get that:
Now that puppet is ready to serve it out, we have to create some files.
1 2 3
1 2 3
1 2 3 4 5 6 7 8 9
The first two steps are going to be to install cygwin, making sure to add git and openssh, then the puppet client software (making sure to point to your linux host as the master).
When this is done, stop the windows puppet service and make sure it is not set for startup. We’re going to control this process with a custom task schedule.
Next, add the path to your cygwin bin folder to the PATH environment variable. If you don’t know how, it’s probably something similar to C:\cygwin\bin, and you’ll add it according to this guide. You’re close now!
Using cygwin, generate a public/private key pair (if using git+ssh) without a password and give the public key to the master box.
If you’ve done it right, you can clone the repo in cygwin without a password using this line:
The last step is to generate a cert and sign it.
From the client:
Then on the master:
The client should now finish and download your git code! Congrats!
However, this isn’t automagic yet. To do that, create a scheduled task that runs every 2 minutes (or whenever) that runs a daemon file.
The easiest way is to create C:\Program Files\Puppet Labs\Puppet\bin\puppet_daemon.bat which contains:
1 2 3 4
Congrats. You’re done! To test, make a change to the git repo and wait two minutes!