HomePhorge

(PUP-1596) Interpolate settings inside an environment.conf
e65b6457732bUnpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

(PUP-1596) Interpolate settings inside an environment.conf

The initial implementation of environment.conf handling for directory
environments did not take into account the interpolation of settings
within environment.conf settings. The issue was further complicated by
the fact that environment.conf settings are post-processed to make
relative paths absolute from the context of the environment directory.

For instance, given a directory environment
'/some/environments/interpolated' with an environment.conf where
'modulepath=$basemodulepath:relative/modules', lookup of the setting via
Puppet.setting.value(:modulepath, 'interpolated') would previously
create a directory environment via the loader, which would read the
environment.conf and create an EnvironmentConf object, and return a
modulepath looking like
"/some/environments/interpolated/$basemodulepath:/some/environments/interpolated/relative/modules"
This would then be interpolated by the Settings system, inserting the
value of $basemodulepath.

A direct call to the instatiated
Puppet::Node::Environment#full_modulepath, by contrast would return just
the pre-interpolated path. Neither was correct.

The problem was that the environment.conf values were being obtained
and post-processed for absolute paths, then passed to the instantiated
environment before settings ever had a chance to be involved.
Historically, this was because settings for directory environments were
based on the values obtained from an instantiated env instance, since
the settings were all hard defaults based solely on the environment
directory.

To fix this, the action of obtaining an environment's configuration has
been separated from the process of obtaining an environment, and a
get_conf() method has been added to the Environments loaders. For a
Directories loader, it returns the EnvironmentConf for the requested
directory environment. This is now used by Settings to obtain setting
information for a given directory environment. And Settings values for
an environment are considered canonical and used by the loader to
instantiate new directory environments.

The other half of the fix is a bit of logic in
EnvironmentConf#absolute() which does not prepend the environment
directory to a path section that begins with a '$' since this indicates
a configuration setting to be interpolated by the Settings system. This
allows the timing between standing up an EnvironmentConf instance, and
interpolating it within Settings to be separated.

Details

Provenance
Josh Partlow <joshua.partlow@puppetlabs.com>Authored on
vanmeeuwenPushed on Jun 2 2015, 2:22 PM
Parents
rPU574115abbab2: (PUP-1596) Read environment.conf for new directory environments
Branches
Unknown
Tags
Unknown

Event Timeline

Josh Partlow <joshua.partlow@puppetlabs.com> committed rPUe65b6457732b: (PUP-1596) Interpolate settings inside an environment.conf (authored by Josh Partlow <joshua.partlow@puppetlabs.com>).Mar 19 2014, 1:21 AM