You might need to increase the log level from info
(the default) to debug
to gather additional information when troubleshooting a problem with Puppet services. For example, increasing the log level for puppetserver
is helpful for troubleshooting.
Version and installation information
Puppet version: 4.0 to latest
OS: Any
Installation type: Any
Solution
Change the log level by editing the service’s logback.xml
root-level
setting and restarting the service. You can do this manually, or you can install a module that uses a task to complete the steps.
Note: debug
-level logs fill up disk space quickly. When you finish gathering information, change the log level back to info
. Before you send debug
-level logs to anyone, review them for sensitive information, such as hostnames and IP addresses.
Set the log level manually
The following command uses puppet apply
with an Augeas resource to edit the service’s logback.xml
root-level
setting and restart the service.
Set the value for FACTER_level
to: debug
to increase the log level, or info
to decrease the log level to the default level. Set the value for FACTER_service
to the affected service: puppetserver
or puppetdb
FACTER_level="<DEBUG OR INFO>" FACTER_service="<SERVICE NAME>" puppet apply -e "augeas {'toggle logging level': incl => \"/etc/puppetlabs/$::service/logback.xml\", lens => 'Xml.lns', context => \"/files/etc/puppetlabs/$::service/logback.xml/configuration/root/#attribute\", changes => \"set level \'$::level\'\"}~> service {\"$::service\": ensure => running }"
Examples
Set puppetdb
to debug
-level logging:
# FACTER_level="debug" FACTER_service="puppetdb" puppet apply -e "augeas {'toggle logging level': incl => \"/etc/puppetlabs/$::service/logback.xml\", lens => 'Xml.lns', context => \"/files/etc/puppetlabs/$::service/logback.xml/configuration/root/#attribute\", changes => \"set level \'$::level\'\"}~> service {\"$::service\": ensure => running }"
Output:
Notice: Compiled catalog for osp-puppetdb.platform9.puppet.net in environment production in 0.23 seconds
Notice: /Stage[main]/Main/Augeas[toggle logging level]/returns: executed successfully
Notice: /Stage[main]/Main/Service[puppetdb]/ensure: ensure changed 'stopped' to 'running'
Notice: Finished catalog run in 0.27 seconds
Set puppetdb
to info
-level logging:
# FACTER_level="info" FACTER_service="puppetdb" puppet apply -e "augeas {'toggle logging level': incl => \"/etc/puppetlabs/$::service/logback.xml\", lens => 'Xml.lns', context => \"/files/etc/puppetlabs/$::service/logback.xml/configuration/root/#attribute\", changes => \"set level \'$::level\'\"}~> service {\"$::service\": ensure => running }"
Output:
Notice: Compiled catalog for osp-puppetdb.platform9.puppet.net in environment production in 0.19 seconds
Notice: /Stage[main]/Main/Augeas[toggle logging level]/returns: executed successfully
Notice: /Stage[main]/Main/Service[puppetdb]: Triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.50 seconds
Set the log level via a task with Bolt
Before you begin: You must install the puppetlabs-support_tasks
module and Bolt on a workstation to run the task.
Note: This task restarts the target Puppet service. This restart will cause connection error(s) for any agent requests which happen during the restart. You can safely ignore these error(s) while the task runs in the background. This task assumes that the puppetserver
and puppetdb
services are installed on the same node. This task doesn’t support configurations where infrastructure services are on different nodes.
Run the task using Bolt and SSH
Run the task against the target infrastructure node. Change the value for loglevel
to debug
to increase the log level, or info
to decrease the log level to the default level and change the value for service to the affected service: puppetserver
or puppetdb
bolt task run support_tasks::st0009_change_pe_service_loglevel loglevel="<DEBUG OR INFO>" service="<SERVICE NAME>" -n $(puppet config print certname) --modulepath="/etc/puppetlabs/code/environments/production/modules"
Example To set the debug level for the puppetserver
service, on the primary server run the following:
bolt task run support_tasks::st0009_change_pe_service_loglevel loglevel="debug" service="puppetserver" -t <TARGET NAME> --modulepath="/etc/puppet/modules"
Output:
Started on 192.168.0.20...
Finished on 192.168.0.20:
Found Opensource
Updating 'puppetserver' log level to 'debug'
Notice: Compiled catalog for osp-server.platform9.puppet.net in environment production in 0.32 seconds
Notice: /Stage[main]/Main/Augeas[toggle logging level]/returns: executed successfully
Notice: /Stage[main]/Main/Service[puppetserver]/ensure: ensure changed 'stopped' to 'running'
Notice: Applied catalog in 27.94 seconds
-- ST#0009 Task ended 1579906511 --
{
}
Successful on 1 target: 192.168.0.20
Ran on 1 target in 34.49 sec
Learn more about:
Comments
0 comments
Please sign in to leave a comment.