Puppet logs for Windows agent

Puppet logs

Here is a code snippet that You can use for ensuring that puppet logs for Windows agent are stored in dedicated Event Log.

By default the puppet agent installed on Windows will run as a Windows service. The logs from puppet runs are recorded in Application Event Log. It is very easy to change that behavior, which I would strongly advise as one of the first things to be done after agent installation. Puppet docs clearly define the options to be chosen. In this post, however I would like to present how easily it is to automate this task by putting this code snippet inside basic puppet module.

When the Puppet log gets created

Unless clause of the exec command is being used to ensure that Puppet log is being added just once. Whenever reg query does not return any result the command clause will be executed. The logs will be created. On the other hand, if reg query produces any results, command execution will be skipped.

Creation of the Puppet log

Command part 1 has been taken directly from Puppet docs. It will create separate Puppet log in the Windows Event Log.

Reboot is required

Command part 2 is basically about making sure that command part 1 has been realized. In order to achieve that the Windows server must be rebooted. Next time when puppet runs on the newly started machine the logs from puppet runs will be recorded in the Puppet Event Log.


Leave a Reply