(#17458) Load 'puppet' at the right time

Previously the Puppet::Util.which method tried to compensate for the
puppet.rb file not being loaded at the right time by trying to load it
itself. When a performance improvement was added (commit 20efe94) to
check if this needed to be done it broke the codepath for executing
external puppet-* commands.

This commit fixes this by requiring 'puppet' at the right place in the
entry point (Puppet::Util::CommandLine) and removing the workaround in
Puppet::Util.which.

Paired-with: Josh Cooper <josh@puppetlabs.com>
Merge branch 'issue/2.7.x/17458-puppet-fall-down-go-boom' of git://github.com/zaphod42/puppet into 2.7.x

* 'issue/2.7.x/17458-puppet-fall-down-go-boom' of git://github.com/zaphod42/puppet:
  (#17458) Load 'puppet' at the right time
Revert "(#17458) Load 'puppet' at the right time"

Commit b5ed15baadffb22b789cebfab7a76e2ab43c7d14 attempted to require
'puppet' at the right time, but failed. The command_line required puppet
before the application was required and its run_mode determined. As a
result, `puppet master` was using the default :user run_mode, causing
its pidfile to be named 'agent.pid' among other things.

This comit reverts b5ed15ba.
(#17458) Partial revert of "don't rebuild regexp every time"

In commit, 20efe94, a change was made to Puppet::Util.absolute_path? to
require the Puppet module only if necessary. This was done as an
optimization since re-requiring a file is much slower than checking if a
constant is defined.

However, defined?(Puppet) is always true when called within the
Puppet::Util.absolute_path? method, so effectively, absolute_path? would
never require the Puppet module, when previously it used to, in certain
exceptional flows.

In the normal flow, it wasn't an issue, because when puppet runs an
internal subcommand (Application), the app requires the Puppet module,
which loads features, which creates an autoloader, which calls the
absolute_path?  method.  At this point, requiring puppet is not needed.

However, if an external subcommand was specified, e.g.  `puppet foo`,
where `puppet-foo` is an external executable, or if no subcommand was
specified, e.g.  `puppet`, the CommandLine would attempt to resolve the
external subcommand using Puppet::Util.which, which calls absolute_path?
at a time when the Puppet module and features haven't been loaded,
causing #17458.

Ideally, the exceptional cases should be requiring puppet rather than
relying on the absolute_path?  method to do so.  However, in 3.x, this
entire logic has been reworked.  In 3.x, the default confdir/vardir
locations are solely based on whether we're running as root or not, and
not the application's run_mode setting.  As a result, we can and do
require puppet early on.

For 2.7.x, the safest thing is to revert the change in the require
'puppet' behavior.
(#17458) Add acceptance test for executing external subcommands

Commit 20efe94 broke running `puppet` and `puppet-*` external
subcommands. This adds an acceptance test to make sure puppet doesn't
blow up when given an unknown external subcommand.

Paired-with: Josh Cooper <josh@puppetlabs.com>
Merge pull request #1271 from joshcooper/ticket/2.7.x/17458-undo-performance-fix

(#17458) Undo minor performance change in 2.7.x
Merge remote-tracking branch 'upstream/2.7.x' into 3.0.x

* upstream/2.7.x:
  (#17458) Add acceptance test for executing external subcommands
  (#17458) Partial revert of "don't rebuild regexp every time"
  Revert "(#17458) Load 'puppet' at the right time"
  (#17458) Load 'puppet' at the right time
Merge remote-tracking branch 'upstream/3.0.x'

* upstream/3.0.x:
  (#17458) Add acceptance test for executing external subcommands
  (#17458) Partial revert of "don't rebuild regexp every time"
  Revert "(#17458) Load 'puppet' at the right time"
  (#17458) Load 'puppet' at the right time
(#17458) Re-enable performance fix

Previously, commit 20efe94 tried to only require puppet if it wasn't
loaded. However, defined?(Puppet) was always true when called by
absolute_path?, so the require was never executed.

Commit 327aff5, changed it to always require puppet, due to the way
puppet is required in 2.7.x. However, in 3.0.x, puppet is required at
the very beginning of command_line.rb (which is why 3.0.x didn't have
the same problem as 2.7.x).

This commit restores the behavior in 3.0.x, of never requiring puppet
from the absolute_path? method. I didn't want to make this change in the
merge commit, so it's clear why the logic is different.
Merge remote-tracking branch 'upstream/3.0.x'

* upstream/3.0.x:
  (#17458) Re-enable performance fix
Merge remote-tracking branch 'upstream/master'