Create an environment
Create an environment by adding a new directory of configuration data.
- Inside your code directory, create a directory called environments.
- Inside the environments directory, create a directory with the same name as your new environment.
- Inside that directory, create a
modules
directory and amanifests
directory. These two directories contain your Puppet code. - Configure a
modulepath
:- Set
modulepath
in itsenvironment.conf
file . If you set a value for this setting, the globalmodulepath
setting frompuppet.conf
is not used by an environment. - Check the
modulepath
by specifying the environment when requesting the setting value:
$ sudo puppet config print modulepath --section server --environment test /etc/puppetlabs/code/environments/test/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules.
In Puppet Enterprise (PE), every environment must include/opt/puppetlabs/puppet/modules
in itsmodulepath
, because PE uses modules in that directory to configure its own infrastructure. - Set
- Configure a main manifest:
- Set manifest in its
environment.conf
file. As with the globaldefault_manifest
setting, you can specify a relative path (to be resolved within the environment’s directory) or an absolute path. - Lock all environments to a single global manifest with the
disable_per_environment_manifest
setting — preventing any environment setting its own main manifest.
- Set manifest in its
- To specify an executable script that determines an environment’s config
version:
- Specify a path to the script in the
config_version
setting in itsenvironment.conf
file. Puppet runs this script when compiling a catalog for a node in the environment, and uses its output as the config version. If you specify a value here, the globalconfig_version
setting frompuppet.conf
is not used by an environment.
If you’re using a system binary like gitrev-parse
, 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’s PATH. - Specify a path to the script in the
Results
Example environment.conf file:
# /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
Related topics: Deploying environments with r10k, Code Manager control repositories, disable_per_environment_manifest