The codedir is the main directory for Puppet code and data, and is used by Puppet master, Puppet apply, but not by Puppet agent. It contains environments (which contain your manifests and modules), a global modules directory for all environments, and your Hiera data.
Location
-
*nix:
/etc/puppetlabs/code -
*nix non-root users:
~/.puppetlabs/etc/code -
Windows:
%PROGRAMDATA%\PuppetLabs\code(usuallyC:\ProgramData\PuppetLabs\code)
When Puppet is running as root, a Windows user with administrator privileges, or the puppet user, it will use a system-wide codedir. When running as a non-root user, it will use a codedir in that user's home directory.
When running Puppet commands and services as root or puppet, usually you want to use the system codedir. To use the same codedir as the Puppet agent, or Puppet master, run admin commands such as puppet module with sudo.
config.ru file must explicitly set --codedir to the system codedir. The example config.ru file provided with the Puppet source does this.To configure the location of the codedir in puppet.conf, use the the codedir setting.
puppet.conf, and instead uses the jruby-puppet.master-code-dir setting in puppetserver.conf. When using a non-default codedir, you must change both settings.Interpolation of $codedir
$codedir variable in the value of any other setting in puppet.conf:
[master]
environmentpath = $codedir/override_environments:$codedir/environments
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
The codedir contains environments, including manifests and modules, a global modules directory for all environments, and Hiera data.
environments: Contains alternate versions of themodulesandmanifestsdirectories, to enable code changes to be tested on smaller sets of nodes before entering production.modules: The main directory for modules.