The Agent and Server Model
text
Agent node Puppet Server (port 8140, HTTPS)
---------- --------------------------------
1. Agent runs Facter, collects facts
2. Agent sends facts ───────────────────────► 3. Server compiles catalog for this node
(code + Hiera + facts + ENC/site.pp)
5. Agent applies catalog ◄───────────────── 4. Server sends catalog
6. Agent sends report ──────────────────────► 7. Server stores report, sends to PuppetDB
(default: every 30 minutes)
Every connection uses TLS with certificates. The server has a built-in Certificate Authority (CA). Each agent needs a certificate that the CA has signed. After that both sides authenticate each other.
Install Puppet Server and Agent
Package names: Open-source Puppet 7 reached end of life in April 2025. For new setups use a supported release line: Puppet Core 8 (maintained by Perforce) or the community build OpenVox. Package and repository names differ by distribution, so use the current official installation page for your choice. The commands below use the common Puppet package layout, and OpenVox uses openvox-server and openvox-agent names with the same directories and commands.
bash
# Server (example for Puppet packages)
sudo dnf install -y puppetserver # or apt install puppetserver
sudo systemctl enable --now puppetserver
sudo ss -tlnp | grep 8140
# Make the commands available
echo 'export PATH=/opt/puppetlabs/bin:$PATH' | sudo tee /etc/profile.d/puppet.sh
# Agent
sudo dnf install -y puppet-agent
sudo /opt/puppetlabs/bin/puppet config set server puppet.example.com --section main
sudo systemctl enable --now puppet
puppet --versio
| Item | Location |
| Configuration | /etc/puppetlabs/puppet/puppet.conf |
| Code | /etc/puppetlabs/code/environments/ |
| SSL files | /etc/puppetlabs/puppet/ssl/ (agent) and /etc/puppetlabs/puppetserver/ca/ (server CA) |
| Server logs | /var/log/puppetlabs/puppetserver/puppetserver.log |
| Agent logs | journalctl -u puppet and /var/log/puppetlabs/puppet/ |
| Reports and state | /opt/puppetlabs/puppet/cache/ |
| JVM memory | /etc/default/puppetserver or /etc/sysconfig/puppetserver (JAVA_ARGS) |
Connect an Agent
bash
# Make sure the agent can resolve and reach the server on 8140
ping puppet.example.com
nc -zv puppet.example.com 8140
# First run: creates a key and certificate signing request (CSR)
sudo puppet agent -t --server puppet.example.com --waitforcert 60
# Info: Creating a new SSL key for web01.example.com
# Info: Caching certificate for ca
# Info: csr_attributes file loading from ...
# Info: Creating a new SSL certificate request for web01.example.com
# Info: Certificate Request fingerprint (SHA256): 9B:F4:...
# Info: Certificate for web01.example.com has not been signed yet
bash
# On the SERVER: see requests, check fingerprint, sign
sudo puppetserver ca list # pending requests
sudo puppetserver ca list --all # all certificates
sudo puppetserver ca sign --certname web01.example.com
sudo puppetserver ca sign --all
# Back on the agent: runs automatically and now gets a catalog
sudo puppet agent -t
Verify before you sign: Compare the fingerprint printed by the agent with the one in puppetserver ca list. Only sign requests that you expect. Anyone who gets a signed certificate can request catalogs for that name.
Certificate Management Commands
| Command | Use |
puppetserver ca list [--all] | Show requests, or all certificates |
puppetserver ca sign --certname NAME | Approve a request |
puppetserver ca revoke --certname NAME | Revoke a certificate (adds it to the CRL) |
puppetserver ca clean --certname NAME | Revoke and delete. Use when removing a node |
puppetserver ca generate --certname NAME | Create key and certificate on the server for a node |
puppetserver ca import | Use your own corporate CA |
puppetserver ca setup | Create the CA on a fresh server |
Re-enrolling a Node (Rebuilt Server)
bash
# Server: remove the old certificate for the name
sudo puppetserver ca clean --certname web01.example.com
# Agent: remove the old SSL directory and request again
sudo systemctl stop puppet
sudo rm -rf /etc/puppetlabs/puppet/ssl
sudo puppet agent -t --waitforcert 60
# Server: sign again
sudo puppetserver ca sign --certname web01.example.com
Autosign: Sign Without Manual Work
For hundreds of cloud nodes, manual signing is too slow. Autosign lets the server approve requests that pass a check. Choose the safest method you can.
| Method | Setting | Security |
| Off (default) | autosign = false | Safest, but manual |
autosign.conf list | autosign = /etc/puppetlabs/puppet/autosign.conf with names or *.example.com | Weak. Anyone who can claim a name gets a certificate |
autosign = true | Sign everything | Never use outside a throwaway lab |
| Policy executable | autosign = /usr/local/bin/policy-autosign.sh | Good: you decide using a challenge password or cloud data |
bash
#!/bin/bash
# /usr/local/bin/policy-autosign.sh (chmod 755, owned by root)
# Puppet Server calls it with the certname as $1 and the CSR on stdin.
certname="$1"
csr=$(cat)
# Extract the challenge password from the CSR
password=$(echo "$csr" | openssl req -noout -text 2>/dev/null | grep -A1 challengePassword | tail -1 | tr -d ' ')
if [ "$password" = "$(cat /etc/puppetlabs/puppet/autosign-secret)" ] \
&& [[ "$certname" =~ ^[a-z0-9-]+\.example\.com$ ]]; then
exit 0 # sign
fi
exit 1 # do not sig
ini
# /etc/puppetlabs/puppet/puppet.conf on the server
[server]
autosign = /usr/local/bin/policy-autosign.sh
yaml
# On the new node BEFORE the first agent run: /etc/puppetlabs/puppet/csr_attributes.yaml
---
custom_attributes:
challengePassword: 'A-long-random-secret-set-by-your-provisioning-tool'
extension_requests:
pp_role: webserver
pp_environment: productio
Provisioning flow: Terraform or cloud-init writes csr_attributes.yaml (with the one-time secret and role), installs the agent, and runs it. The server validates the secret and signs automatically. The role in the certificate becomes a trusted fact.
Important puppet.conf Settings
ini
# Agent: /etc/puppetlabs/puppet/puppet.conf
[main]
server = puppet.example.com
certname = web01.example.com
environment = production
[agent]
runinterval = 30m # default
splay = true # random delay to avoid all nodes hitting the server at once
splaylimit = 10m
noop = false # true = report only, change nothing
report = true
usecacheonfailure = true # use the last good catalog if the server is down
daemonize = true
| Agent command | Meaning |
puppet agent -t | --test: run once, in the foreground, verbose. Use for manual runs |
puppet agent -t --noop | Show what would change without changing |
puppet agent -t --environment dev | Run a different environment once |
puppet agent -t --tags web | Only resources with tag |
puppet agent --disable 'maintenance' | Pause runs, with a reason |
puppet agent --enable | Resume |
puppet config print | Show all settings |
puppet config print runinterval | One setting |
Exit Codes from puppet agent -t
| Code | Meaning |
0 | Run succeeded, no changes |
1 | Run failed or was disabled/locked |
2 | Run succeeded, some resources changed |
4 | Some resources failed |
6 | Both changes and failures |
In scripts: puppet agent -t returns 2 when changes were applied, which is normal. Use --detailed-exitcodes behaviour in CI knowing that 0 and 2 are good, and 4 or 6 are failures.
Firewall and Networking
bash
sudo firewall-cmd --permanent --add-port=8140/tcp && sudo firewall-cmd --reload # RHEL family
sudo ufw allow 8140/tcp # Ubuntu
# Agents also need to resolve the server name: DNS record "puppet" or --server setting
Common SSL Errors
| Error | Cause | Fix |
certificate verify failed ... (certificate not yet valid) | Wrong clock on the agent | Fix time sync with NTP or chrony |
Certificate request does not match/Retrieved certificate does not match private key | Old files from a previous install | Clean on both sides and re-enrol (see above) |
hostname ... not match with the server certificate | Agent connects with a name not in the server certificate | Use server name that is in the cert, or add dns_alt_names when generating the server cert |
Could not request certificate: Connection refused | Server down or firewall closed | Check service and port 8140 |
This node is waiting for a signed certificate | Request not signed | puppetserver ca sign |
Could not retrieve catalog from remote server: Error 500 | Compile error on the server | Read puppetserver.log or run puppet agent -t in debug mode |
Certificate is revoked | Node was cleaned | Remove ssl dir and re-enrol |
Practice Tasks
- Build a lab with one server VM and one agent VM, then sign the agent certificate manually
- Break trust by deleting the agent
ssl directory, then restore it by cleaning and re-signing
- Write a policy autosign script with a challenge password and test with
csr_attributes.yaml
- Run
puppet agent -t --noop and then a real run, and note exit codes 0, 2 and 4
- Change
runinterval and splay and watch the report times on the server
Conclusion
Agents ask the server for a catalog over TLS. Sign certificates only after checking, use a policy autosign script with a secret for cloud nodes, set csr_attributes.yaml for trusted facts, and use puppet agent -t --noop before big changes.
Quick Summary: agent gets catalog over 8140; puppetserver ca sign/clean; policy autosign; csr_attributes; exit codes 0/2/4/6.