The primary Puppet agent configuration file is named puppet.conf
, and it is typically located within the agent's main configuration directory, $confdir
. This file is crucial for defining how the Puppet agent behaves, communicates with the Puppet primary server (formerly master), and manages its local environment.
Understanding the $confdir
The $confdir
variable represents the default configuration directory for Puppet on a given system. While the specific path for $confdir
varies by operating system, the puppet.conf
file always resides directly within it.
Common $confdir
Locations
The table below illustrates the typical $confdir
locations for different operating systems:
Operating System | Default $confdir Path |
---|---|
Linux/Unix | /etc/puppetlabs/puppet |
macOS | /etc/puppetlabs/puppet |
Windows Server | C:\ProgramData\PuppetLabs\puppet\etc |
Windows Desktop | C:\ProgramData\PuppetLabs\puppet\etc |
Note: For older Puppet versions or specific custom installations, these paths might differ slightly.
How to Determine the Exact $confdir
To find the precise $confdir
on your system, you can use the Puppet agent command-line tool:
puppet agent --configprint confdir
Executing this command will output the exact path where your Puppet agent expects to find its configuration files, including puppet.conf
.
The Role of puppet.conf
The puppet.conf
file is a plain-text configuration file organized into sections, each enclosed in square brackets (e.g., [main]
, [agent]
, [master]
). These sections group related settings that control various aspects of Puppet's operation.
Key Sections for Puppet Agents
[main]
: Contains global settings that apply to all Puppet applications (agent, apply, etc.) unless overridden in a more specific section.[agent]
: Holds settings specifically for the Puppet agent application. This is where you would configure parameters like theserver
(the primary server's hostname),runinterval
,certname
, andenvironment
.[master]
: Whilepuppet.conf
on an agent primarily focuses on[agent]
and[main]
, if the same file is used on a primary server, this section would contain settings relevant to the primary server's operation.
Example puppet.conf
Snippet for an Agent
[main]
certname = myagent.example.com
server = puppet.example.com
logdir = /var/log/puppetlabs/puppet
rundir = /var/run/puppetlabs
[agent]
classfile = $vardir/classes.txt
localcacert = $ssldir/certs/ca.pem
report = true
runinterval = 30m
Configurable Location (with a Catch)
While the default location of puppet.conf
is consistently $confdir/puppet.conf
, its location is technically configurable. However, this configurability is limited: the config
setting, which dictates the path to puppet.conf
, can only be set via the command line when invoking Puppet. This means that for regular Puppet agent operations, the file is always expected at the default $confdir/puppet.conf
location, making command-line overrides a less common scenario for agents and primarily used for testing or specific debugging purposes.
In practice, Puppet administrators rarely alter the puppet.conf
file's path for agents, relying on the standard $confdir
location for consistency and ease of management.