environment.conf
:
Per-environment settings
Environments are isolated groups of agent nodes. Any environment can contain an
environment.conf
file. This file can override several
settings whenever the primary server is serving nodes assigned to that
environment.
Location
Each environment.conf
file is stored in an environment. It will be at the top level of its home
environment, next to the manifests
and modules
directories.
For example, if your environments are in the default directory ($codedir/environments
), the test
environment’s config file is located at $codedir/environments/test/environment.conf
.
Example
# /etc/puppetlabs/code/environments/test/environment.conf
# Puppet Enterprise requires $basemodulepath; see note below under "modulepath".
modulepath = site:dist:modules:$basemodulepath
# Use our custom script to get a git commit for the current state of the code:
config_version = get_environment_commit.sh
Format
The environment.conf
file uses the same INI-like
format as puppet.conf
, with one exception: it cannot
contain config sections like [main
]. All settings in
environment.conf
must be outside any config
section.
Relative paths in values
Most of the allowed settings accept file paths or lists of paths as their values.
If any of these paths are relative paths — that is, they start without a leading slash or drive letter — they are resolved relative to that environment’s main directory.
For example, if you set config_version =
get_environment_commit.sh
in the test
environment, Puppet uses the file at /etc/puppetlabs/code/environments/test/get_environment_commit.sh
.
Interpolation in values
The settings in environment.conf
can use the values
of other settings as variables (such as $codedir
). Additionally, the config_version
setting can use the special $environment
variable, which gets replaced with the
name of the active environment.
The most useful variables to interpolate into environment.conf
settings are:
-
$basemodulepath
— useful for including the default module directories in themodulepath
setting. We recommend Puppet Enterprise (PE) users include this in the value ofmodulepath
, because PE uses modules in thebasemodulepath
to configure orchestration and other features. -
$environment
— useful as a command line argument to yourconfig_version
script. You can interpolate this variable only in theconfig_version
setting. -
$codedir
— useful for locating files.
Allowed settings
environment.conf
file can override these
settings: -
modulepath
-
The list of directories Puppet loads modules from.
If this setting isn’t set, themodulepath
for the environment is:
That is, Puppet adds the environment’s modules directory to the value of the basemodulepath setting from<MODULES DIRECTORY FROM ENVIRONMENT>:$basemodulepath
puppet.conf
, with the environment’s modules getting priority. If the modules directory is empty of absent, Puppet only uses modules from directories in the basemodulepath. A directory environment never uses the globalmodulepath
frompuppet.conf
. -
manifest
-
The main manifest the primary server uses when compiling catalogs for this environment. This can be one file or a directory of manifests to be evaluated in alphabetical order. Puppet manages this path as a directory if one exists or if the path ends with a slash (
/
) or dot (.
).If this setting isn’t set, Puppet uses the environment’s
manifests
directory as the main manifest, even if it is empty or absent. A directory environment never uses the globalmanifest
frompuppet.conf
. -
config_version
-
A script Puppet can run to determine the configuration version.
Puppet automatically adds a config version to every catalog it compiles, as well as to messages in reports. The version is an arbitrary piece of data that can be used to identify catalogs and events.
You can specify an executable script that determines an environment’s config version by setting
config_version
in its environment.conf file. Puppet runs this script when compiling a catalog for a node in the environment, and use its output as the config version.Note: If you’re using a system binary likegit rev-parse
, make sure to specify the absolute path to it. Ifconfig_version
is set to a relative path, Puppet looks for the binary in the environment, not in the system’sPATH
.If this setting isn’t set, the config version is the time at which the catalog was compiled (as the number of seconds since January 1, 1970). A directory environment never uses the global
config_version
frompuppet.conf
.
-
environment_timeout
-
How long the primary server caches the data it loads from an environment. If present, this overrides the value of
environment_timeout
from puppet.conf. Unless you have a specific reason, we recommend only settingenvironment_timeout
globally, in puppet.conf. We also don’t recommend using any value other than0
orunlimited
.For more information about configuring the environment timeout, see the timeout section of the Creating Environments page.