(#16376) Fix rails compatibility layer for activerecord < 3.0

Previously an alias was attempted between scope and named_scope to allow older
activerecord versions (< 3.0) to work with the inventory service while also
supporting modern activerecord. The scope alias failed because
Puppet::Rails::InventoryNode inherits from ActiveRecord::Base, which has a
scope method already. So activerecord's scope method is found instead of the
intended alias target. This commit removes the alias and simply switches on
activerecord version to use the correct scope (AR >= 3.0) or named_scope (AR <
3.0) method.
fail better in package repo rake tasks

This commit modifies the top level Rakefile to only
load the packaging repo yaml file if it exists, as
well as provide some error handling for other unwanted
conditions that may arise as a result of trying to
set up the packaging repo.

Signed-off-by: Moses Mendoza <moses@puppetlabs.com>
(#16585) Remove dead ldapnodes setting

This setting has been dead code since 0.24.0, and its value is never read.
This commit removes it.
(maint) Add .yardopts file

This patch makes it easy to generate documentation, including private
methods.  The assumption is that code will be marked up in markdown
style yard comments.  YARD tags are documented at: [YARD Tags
Overview](http://rubydoc.info/docs/yard/file/docs/Tags.md)

The YARD documentation is currently intended for Puppet developers and
community contributors.  While useful for end users, YARD documentation
is not intended for new users or end users who are not developing on
Puppet.
(maint) Add yard generated documentation to git ignore

This patch simply adds the yard generated documentation to the gitignore
list.
(#16637) Add spec test for non-root puppet master confdir and vardir

This patch simply adds test coverage to catch regressions in
[16637](http://projects.puppetlabs.com/issues/16637)
(#16637) Fix default confdir and vardir with puppet master as normal user

Without this patch `puppet master` will select the wrong default confdir
and vardir values when running as a non root user.  This is a problem
because permission denied errors result trying to create the system
directories when running as a non-system user.

This patch fixes the problem by removing the explicit check for the
master run mode in Puppet::Util::RunMode#which_dir
(#15717) Require puppet/run in the agent

Commit 81c73fd0d0d0a9ad4a7f2cb5386d5956739a89aa had accidentally removed
any requires of the `puppet/run` file and so the code needed for kick
was not being loaded. This adds loading of that file back into the agent
application.
(#15717) Allow pluginsync as an option to Puppet::Run

Commit 62420c6ff02133e7bf6254cff83ddb3511a1ea41 changed the way that
agents decided to perform a pluginsync to have a flag passed in. The
initialize method of Puppet::Run tries to validate the options passed in
and failed when it recieved the new option. This makes the new option
validate and restores the ability to use puppet kick.
(#16757) Only load rubygems in bin/puppet

Under some setups it is necessary that we don't load rubygems ourselves (such
as running bundler in stand-alone mode). This change gives the user control
over loading rubygems, at the cost that they are now required to load rubygems
if loading puppet with rack.
(#16757) Don't load rubygems if bundler is running

If bundler is handling gems we don't want to load rubygems ourselves, as it
can conflict and cause loading of system gems beyond what bundler has set up.
Fix up dependencies for Hiera and Facter in RubyGems.

Since Puppet 3.0 promises to follow semver, the dependencies should take
this into account. This means now that only patch releases of Facter and
Hiera will be pulled in for patch releases of 3.0, and the version
dependency must be bumped for any minor or major release appropriately.

This also fixes a bug in the Hiera dependency due to the segment
comparisons in the RubyGems version resolver. Because there was no `.`
before the `rc` in the current dependency (`1.0.0rc`) this resulted in
the comparator looking at `1.0` and selecting the first version `>=`
than it, in this case `1.1.0.rc`. I assume this is unintended and that
the target was meant to resolve to Hiera `1.0.0`.
(#15717) Acceptance tests for puppet kick

Previously, the acceptance test for #3172 only verified that `puppet
kick` could be given a target host to connect to, and would verify that
exit code 3 was returned. This exit code can mean connect failed, which
is what the test was attempting to verify.

However, exit code 3 can also mean `puppet kick` failed to verify the
SSL server's certificate, or auth.conf doesn't allow access to /run, or
something bad happened on the remote agent end -- in our case #15717.

This commit updates the acceptance test for #3172 so it's clear what
it's actually testing.

It also adds an acceptance test to verify that the master can kick an
agent, and that the agent reports the kick was successful. It also
verifies that running `puppet kick` generates a deprecation warning.

While researching these issues, I've discovered that `--ignoreschedules`
doesn't work and hasn't for sometime, see #5975. The option is also not
documented in the puppet kick documentation.

Also, the `--pluginsync` option doesn't do anything, since in Puppet 3,
pluginsync is enabled by default, and the ability to specify
`--no-pluginsync` doesn't make much sense in an agent/master
environment.
(#15717) Kick agent using its fqdn

Previously, the acceptance test would fail if `puppet kick` verified the
SSL certificate of the target, and the hostname it connected to didn't
match what was in the certificate.

The `agent` string contains the agent hostname as specified in the
configuration file, not the fqdn. Also, the agent and master may be in
different domains.

This commit modifies the test to query the agent for its fqdn, and then
puppet kick's that.
(#16757) Move rubygems require to application entry point

The previous commit removed the side-effect of loading rubygems as a
result of evaluating the `Puppet.features.rubygems?` feature. As a
result, the puppet script was the only place where we loaded rubygems,
breaking rack setups.

This commit moves the loading of rubygems into the
Puppet::Util::CommandLine, which is effectively puppet's entry point
for both command line and rack setsups.

In addition, `Bundler::Setup` doesn't always seem to exist, at least
not in all versions of bundler, so instead we're using `::Bundler` to
detect if it's loaded.

Paired-with: Andy Parker <andy@puppetlabs.com>
(#16757) Deprecate Puppet.features.rubygems?

Loading rubygems inside an library is wrong, it needs to be controlled
by the environment.

Previously, several puppet features relied on the side effect of
loading rubygems as a result of evaluating the feature. This is no
longer necessary now that rubygems loading is handled in the
Puppet::Util::CommandLine entry point.

This commit adds a deprecation warning if `Puppet.features.rubygems?`
is invoked, and reinstates the previous behavior of requiring rubygems
to maintain backwards compatibility.

Paired-with: Andy Parker <andy@puppetlabs.com>
(#16757) Don't require rubygems

Previously, the windows service code was explicitly requiring
rubygems. While not breaking anything, it's not desirable, as the
environment should load rubygems, or not, instead of the service code
itself.

This code changes the daemon batch file to execute rubyw with rubygems
support enabled.

Paired-with: Andy Parker <andy@puppetlabs.com>
(#16757) Prevent using rubygems when bundler is in use

Previously, the `has_rubygems?` method only took into account whether
the `::Gem` constant was defined. However, bundler also defines this
constant. As a result, puppet could load code from rubygem directories
that bundler did not want us to see.

Also, the spec tests failed when invoking rspec via bundler, because
we didn't correctly mock whether rubygems was available or not.

Paired-with: Andy Parker <andy@puppetlabs.com>
(#16801) Remove mongrel references from init scripts

Built-in mongrel support has been removed in Puppet 3.x, so the puppetmaster
init scripts and defaults files should no longer mention them or try to use
them as options. This commit removes the code paths that reference mongrel and
--servertype. It also adds checks to both init scripts to check for multiple
ports or puppetmasters set. In those cases it prints a warning to the user
explaining that only one puppetmaster, on one port, will be started. It also
explains where the setting can be updated.
Maint: Retab puppetmaster init scripts

This commit replaces all 2 space tabs and hard tabs with 4 space tabs and adds
a vim tab explanation at the bottom of both init scripts.