Directories: The cache directory (vardir)
Puppet’s cache directory, sometimes called vardir, contains dynamic or growing data that Puppet creates in the course of its normal operations. Some of this data can be mined for interesting analysis, or to integrate other tools with Puppet. Other parts are just infrastructure and can be ignored.
Location of the vardir directory
Puppet Server’s cache directory defaults to /opt/puppetlabs/server/data/puppetserver.
The cache directory for Puppet agent and Puppet apply can be found at one of the following locations:
- *nix Systems:
/var/opt/puppetlabs/puppet/cache - non-root users:
~/.puppetlabs/opt/puppet/cache - Windows:
%PROGRAMDATA%\PuppetLabs\puppet\cache(usuallyC:\Program Data\PuppetLabs\puppet\cache)
When Puppet is running as either root, a Windows user with administrator privileges, or the puppet user, it will use a system-wide cache directory. When running as a non-root user, it will use a cache directory in that user’s home directory.
The system cache directory is what you usually want to use, since you will usually run Puppet’s commands and services as root or puppet. (Note that admin commands like puppet cert must be run with sudo to use the same directories as Puppet agent or Puppet master.)
Note: When Puppet master is running as a Rack application, the
config.rufile must explicitly set--vardirto the system cache directory. The exampleconfig.rufile provided with the Puppet source does this.
Configuring the location of the cache directory
You can specify Puppet’s cache directory on the command line by using the --vardir option, but you can’t set it in puppet.conf. If --vardir isn’t specified when a Puppet application is started, it will always use the default cache directory location.
Puppet Server uses the jruby-puppet.master-var-dir setting in puppetserver.conf to configure its cache directory.
Interpolation of $vardir
Because the value of the vardir is discovered before other settings, you can reference it with the $vardir variable in the value of any other setting in puppet.conf or on the command line.
For example:
[main]
ssldir = $vardir/ssl
If you need to set nonstandard values for some settings, this allows you to avoid absolute paths and keep your Puppet-related files together.
Contents of the cache directory
The vardir directory contains several subdirectories. Most of these subdirectories contain a variable amount of automatically generated data. Some of them contain notable individual files. Some directories are used only by agent or master processes.
The vardir directory has the following default structure. Most of the files and directories can have their locations changed with settings in puppet.conf. The link for each item goes to its description in the configuration reference.
bucket(bucketdir)client_data(client_datadir)clientbucket(clientbucketdir)client_yaml(clientyamldir)devices(devicedir)lib/facter(factpath)facts(factpath)facts.d(pluginfactdest)lib(libdir) (also plugindest) — Puppet uses this as a cache for plugins (custom facts, types and providers, functions) synced from a Puppet master. Do not directly change it. If you delete it, the plugins will be restored on the next Puppet run.puppet-module(module_working_dir)reports(reportdir) — When thestorereport is enabled, a Puppet master will store all reports received from agents as YAML files in this directory. These can be easily mined for analysis by an out-of-band process.server_data(serverdatadir)state(statedir)agent_catalog_run.lock(agent_catalog_run_lockfile)agent_disabled.lock(agent_disabled_lockfile)classes.txt(classfile) — This file is a favorite for external integration. It lists all of the classes assigned to this agent node.graphs(graphdir) — Agent nodes write a set of.dotgraph files to this directory when graphing is enabled. These graphs can be used to diagnose problems with catalog application, as well as to visualize the configuration catalog.last_run_summary.yaml(lastrunfile)last_run_report.yaml(lastrunreport)resources.txt(resourcefile)state.yaml(statefile)
yaml(yamldir)