How to log puppet agent and master

palto picture palto · May 4, 2012 · Viewed 18.5k times · Source

Puppet writes logging by default to syslog. Why is that? Most software write to some separate logfile. I checked the documentation and there is a mention that you can write to a log file but there was a mention that "This is generally not used." Is it a bad idea?

What is the typical setup for following the puppet logging? Using grep on the /var/log/messages file?

Answer

hajimuz picture hajimuz · Jun 9, 2015

Since your mentioned syslog, I assume you were talking about Debian-like Linux.

Actually there is no need to write your own log facility. Customizing /etc/default/puppet is enough.

# Startup options
DAEMON_OPTS="--logdest /var/log/puppet/puppet.log"

/etc/default/puppet is sourced by /etc/init.d/puppet, so the options you added here will be executed when puppet service is started.

Docs about --logdest options : https://docs.puppetlabs.com/references/3.3.1/man/apply.html#OPTIONS

BTW, the deb package puppet provides for Debian(or Ubuntu) even includes a logrotate configuration file for /var/log/puppet, I don't know why this option is not default.

/var/log/puppet/*log {
  missingok
  sharedscripts
  create 0644 puppet puppet
  compress
  rotate 4

  postrotate
    pkill -USR2 -u puppet -f 'puppet master' || true
    [ -e /etc/init.d/puppet ] && /etc/init.d/puppet reload > /dev/null 2>&1 || true
  endscript
}