puppetlabs/puppet — pull request #2407 by jpartlow (2014-03-03 22:39:14+00:00)
Title: (PUP-1765) Directory env respects cmdline modulepath and manifest

The addition of directory environments in PUP-1118 caused a regression
in the behavior of --modulepath and --manifest set from the commandline.

Three cases are seen:

1) given a '$confdir/environments/production' directory, `puppet apply
-e 'include "modclass"' --modulepath /some/other/modpath` fails to find
the modclass from /some/other/modpath. The same problem is seen if a
specific directory environment such as '--environment direnv' is set
(assuming that direnv exists).

2) given a '$confdir/environments/production' directory, `puppet module
install foo --modulepath /some/other/modpath` installs to
'$confdir/environments/production'. If a specific directory
environments such as '--environment direnv' is set, then it incorrectly
installs to "$confdir/environments/direnv'.

3) given a '$confdir/environments/production' directory, `puppet master
--manifest /some/other.pp` does not execute '/some/other.pp' when an
agent calls in without specifying an environment.

To fix these cases we are now explicitly overriding the configured
environment with the stored :cli modulepath and/or manifest setting,
both at application run time and when handling a v1 http api call.