Puppet Troubleshooting: Debug Runs, Read Errors, Fix Common Problems Step by Step

Puppet Training Course 26 min min read Updated: Nov 17, 2026 Intermediate
Puppet Troubleshooting: Debug Runs, Read Errors, Fix Common Problems Step by Step
Intermediate Topic 1 of 3

A Method That Works

  1. Read the first error, not the last. Later errors are often caused by it
  2. Decide where it failed: compile (on server) or apply (on agent)
  3. Reproduce it in the smallest way: puppet apply -e '...' or one node with --noop
  4. Add detail: --debug, --trace, puppet lookup --explain
  5. Fix one thing, rerun, confirm. Then add a test so it cannot return

Compile Error or Apply Error?

Message starts withWhereTypical causes
Error: Could not retrieve catalog from remote serverCompile on the serverSyntax, missing class, bad Hiera data, duplicate declaration, missing parameter
Error: Evaluation Error: ...CompileWrong type, undefined variable, function error
Error: Failed to apply catalogApply on agentDependency cycle, other catalog problems
Error: /Stage[main]/.../Package[x]/ensure: change from absent to present failedApplyA resource failed: package not found, service will not start, file permission
Warning: ... Skipping because of failed dependenciesApplyA required resource failed earlier. Fix the earlier one

Run with More Detail

bash sudo puppet agent -t # normal, verbose sudo puppet agent -t --noop # what would change sudo puppet agent -t --debug 2>&1 | tee /tmp/puppet-debug.log sudo puppet agent -t --trace # include Ruby stack traces for internal errors sudo puppet agent -t --evaltrace # list every resource with timing sudo puppet agent -t --summarize # statistics at the end sudo puppet agent -t --tags nginx # only part of the catalog sudo puppet apply --debug --noop site.pp puppet config print --section agent

The Server Side

bash sudo tail -f /var/log/puppetlabs/puppetserver/puppetserver.log sudo journalctl -u puppetserver -f sudo grep -i 'error' /var/log/puppetlabs/puppetserver/puppetserver.log | tail -20 # Compile a catalog on the server for one node and read the errors sudo puppet catalog compile web01.example.com --environment production | head # Raise server log level temporarily (logback.xml: <root level="debug">) and reload sudo systemctl reload puppetserver

Common Errors and Fixes

Error message (shortened)CauseFix
Syntax error at '}' / Could not parse for environmentMissing comma, brace or quotepuppet parser validate file.pp. Look just above the reported line
Evaluation Error: Unknown variable: 'foo'Variable not defined in scope, or a fact missingDefine it, check spelling, use $facts['x'] and dig, or set strict variables on purpose
Could not find class ::profile::nginxWrong name, wrong file path, module not deployedCheck manifests/nginx.pp, puppet module list --modulepath, r10k run
Duplicate declaration: Package[git] is already declaredTwo classes declare the same resourceUse ensure_packages(['git']), or declare it in one place
Duplicate declaration: Class[X] is already declaredclass { 'X': } used twiceUse include and Hiera instead of resource-like declarations
Evaluation Error: Error while evaluating a Resource Statement, Class[X]: expects a value for parameter 'y'Required parameter has no valueAdd a default or Hiera data (X::y)
parameter 'port' expects an Integer value, got StringType mismatch (often from YAML quotes)Fix the data (8080 not '8080') or the type
Found 1 dependency cycleResources depend on each otherRemove one relationship. Draw with --graph
Could not find resource 'Service[nginx]' for relationshipRelationship target is not in catalogDeclare it or include the class that does
Evaluation Error: Unknown function: 'foo'Missing module or older versionAdd module to Puppetfile and deploy
Could not evaluate: Execution of '/usr/bin/dnf -d 0 -e 1 -y install foo' returned 1Package not found / repo problemRun the command by hand, add repo, fix the name
Could not enable/start serviceConfig error or port in usesystemctl status, journalctl -xe, test config
Cannot alias File[/x] to [...]; resource already declaredSame path declared twice with different titlesUse one resource per path
Failed to parse template ...EPP/ERB syntax or missing variablepuppet epp validate, check parameters passed
Could not autoload ...Class in wrong file, bad Ruby in libFix naming, ruby -c the file
Server Error: Failed when searching for node ...ENC or classification errorTest the ENC script by hand
Error: Could not find data item 'x' in any Hiera data file and no default suppliedMissing dataAdd to Hiera or give a default value, use puppet lookup --explain

Find Which File Causes the Problem

bash puppet lookup profile::nginx::port --node web01.example.com --explain puppet apply --noop --modulepath ./modules -e 'include profile::nginx' puppet resource package nginx puppet describe file | less # check attribute names and allowed values puppet module list --tree puppet config print modulepath environmentpath

Problem: Resources Change on Every Run

If the report shows the same resource changing each run, the code is not idempotent. This causes noise, risk and wasted time.

PatternWhy it happensFix
exec with no guardRuns every timeAdd creates, unless, onlyif, or refreshonly
File content has a timestamp or random valueContent differs each runRemove dynamic parts or generate once
mode => 644 (number) or 0644 unquotedPuppet parses differentlyQuote: '0644'
package with ensure => latestUpgrades whenever a new version appearsPin a version or use installed
Service starts but status check failsWrong status or hasstatusSet a status command
user password hash differs between OSDifferent hash formatUse a correct hash for the OS
Resource managed in two placesEach class sets a different valueOne owner per resource
bash # Find resources that change on the second run sudo puppet agent -t # first run sudo puppet agent -t # second run: look for lines starting with "Notice: /Stage[main]..." sudo puppet agent -t --show_diff | head -40 # see what changed in files

Problem: Agent Cannot Contact Server

bash c -zv puppet.example.com 8140 curl -sk https://puppet.example.com:8140/status/v1/simple openssl s_client -connect puppet.example.com:8140 -servername puppet.example.com </dev/null 2>/dev/null | openssl x509 -noout -subject -issuer -dates date; chronyc tracking # clock must be right puppet config print server certname ssldir

Look back at the certificate lesson for the SSL fixes. Time difference, wrong server name and old certificates are the three most common reasons.

Problem: Slow Runs

bash sudo puppet agent -t --evaltrace --summarize 2>&1 | tail -30 cat /opt/puppetlabs/puppet/public/last_run_summary.yaml | grep -A12 '^time' facter --timing 2>&1 | sort -t: -k2 -n | tail # which fact is slow? (use --timing in your Facter version)
Slow partCauseFix
config_retrievalCatalog compile is slow or facts are slowServer resources, slow facts, huge Hiera data
packagePackage manager is slowLocal mirror, avoid latest
Many file resourcesLarge directory with recurse => trueUse a package or archive, use checksum => mtime
execLong commands, timeoutRun once with creates, move to Bolt

Problem: Agent Run Is Locked or Disabled

bash # Error: Skipping run of Puppet configuration client; administratively disabled (Reason: 'maintenance') sudo puppet agent --enable # Error: Run of Puppet configuration client already in progress ps aux | grep '[p]uppet agent' sudo rm -f /opt/puppetlabs/puppet/cache/state/agent_catalog_run.lock # ONLY if no puppet process is running

Isolate With a Tiny Test

bash # Put the failing resource in a file and run it alone cat > /tmp/t.pp <<'EOF' file { '/tmp/demo.conf': ensure => file, content => epp('profile/demo.conf.epp', { 'port' => 8080 }), } EOF sudo puppet apply --modulepath ./site-modules:./modules /tmp/t.pp --debug --noop

Useful Debug Techniques in Code

puppet otice("DEBUG port = ${port}, type = ${type($port)}") notice(inline_epp('<%= $facts["os"]["family"] %>')) $data = lookup('profile::nginx::vhosts', Hash, 'deep', {}) notice(stdlib::to_json_pretty($data)) # view a structure clearly (stdlib) # Stop here to inspect # fail("STOP: reached this line")

When to Ask for Help

  • Include: Puppet version, OS, the exact error text, a minimal example that fails
  • Search the error text in the module's issues and the community Slack or forum
  • Check the module's changelog for breaking changes
  • For OpenVox or Puppet differences, look at the project's release notes and issue tracker

Practice Tasks

  1. Cause a duplicate declaration on purpose and fix it with ensure_packages
  2. Create a dependency cycle and read the error
  3. Create a non-idempotent exec, spot it in the second run, and fix it with creates
  4. Misspell a Hiera key and find it with puppet lookup --explain
  5. Read puppetserver.log while an agent hits a compile error

Conclusion

Troubleshoot by locating the stage (compile or apply), reading the first error, reproducing in a small test, and using --debug, puppet lookup --explain and server logs. Fix non-idempotent resources, and add tests to prevent regressions.

Quick Summary: first error; compile vs apply; --debug/--trace/--evaltrace; duplicate declaration; cycles; idempotence; lock files.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators