Merge pull request #2303 from kylog/maint/fix-rspec-key

(maint) Fix another broken rspec restriction
Revert "Merge branch 'pull-2137'"

This reverts commit a20b16bb70446d43c51340f72c821fc3a93c7cb6, reversing
changes made to 00579976264da4b2b8492bb664291b9ba0d5987c.

Unfortunately this change introduced a number of problems that need to
be addressed before this code can be released.

1) The yum provider is always holdable

The package type detects the ability to hold packages based on the
presence of the #hold method. Even though there is a guarding clause
around the `has_feature :holdable` in the provider it's bypassed when it
fails since the provider defines the #hold method.

This ties into:

2) Holding a package without the yum-plugin-versionlock raises errors

Since the plugin isn't available but the provider looks like it's
holdable, applying a resource like:

    package { 'bash':
      ensure => held,
    }

results in a backtrace since `yum versionlock` returns 1, and a
Puppet::ExecutionFailure is raised.

3) Held packages are not idempotent

When the yum versionlock plugin is installed, the resulting resource is
not idempotent because the ensure value is always being changed from
$version to 'held':

    [root@localhost puppet]# puppet resource package bash ensure=held
    Notice: /Package[bash]/ensure: ensure changed '4.1.2-15.el6_4' to 'held'
    package { 'bash':
      ensure => '4.1.2-15.el6_4',
    }
    [root@localhost puppet]# puppet resource package bash ensure=held
    Notice: /Package[bash]/ensure: ensure changed '4.1.2-15.el6_4' to 'held'
    package { 'bash':
      ensure => '4.1.2-15.el6_4',
    }
(maint) Adding .ruby-version and .ruby-gemset to .gitignore for RVM users.
(maint) Fix acceptance test failure caused by backtrace preservation
change (GH-2293).
We should not be accessing the exception object from the else clause of
the begin/rescue/else.
(DOCUMENT-22) Clarify matching of crontab entries

This updates the documentation to be consistent with behavior introduced in
commit da9162c.
(PUP-1411) Initialize OpenSSL before starting TCP connection

Ruby's Net::HTTP#connect method makes a TCP connection before it creates
the OpenSSL::SSL::SSLContext and invokes the SSLSocket#connect method:

    def connect
      s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }
      if use_ssl?
        ...
        @ssl_context = OpenSSL::SSL::SSLContext.new
        s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
        ...
      end
      ...
      timeout(@open_timeout) { s.connect }

Between the time that the TCP connection is established (TCPSocket.open)
and when the client starts the SSL handshake (SSLSocket#connect), the server
must hold the TCP connection open[1].

The first time this code path is taken on the client, the call to
SSLContext.new causes the openssl library to be initialized. This can
take a non-trivial amount of time and is highly platform dependent, e.g.
openssl will initialize the cryptographically strong pseudo-random
number generator. On Windows, this typically calls CryptGenRandom among
other things.

In our CI environment, we are seeing this call take upwards of 7
seconds on Windows agents. If the agent connects to a webrick
puppetmaster, then the server will only hold the connection open for 6.2
seconds. See redmine #4762 and commit 711344836. This can lead to the
puppetmaster closing the connection, to protect against DoS attacks.

This commit ensures that we initialize the openssl library prior to
establishing the TCP connection. This reduces the amount of time the
server needs to wait for the client to send the CLIENT_HELLO message and
decreases the likelihood that the server will timeout the connection
unnecessarily.

[1] https://bugs.ruby-lang.org/issues/9459
(PUP-1411) Increase CLIENT_HELLO timeout

Previously, if a client established a TCP connection to the webrick server,
but the server did not receive any data within 6.2 seconds, the server
would close the connection, and report that the client disconnected.

The error message is actually misleading, because if the client did
actively disconnect, e.g. sent FIN or RST, then IO.select would report that the
socket is ready and timeout would not be reached.

This commit increases the timeout to 10 seconds and updates the error
message to more clearly say that the client did not send any data
before the timeout expired.

Note that we perform this check, because OpenSSL's SSL_accept will block
indefinitely, since the underlying socket is blocking by default.
(pup-640) Update report schema for error events

Previously, special handling was added to synthesize a report
event even when the property application failed early. However,
when this change was made the report schema wasn't updated,
so the schema did not allow for several fields in the event
to be null (as they are for one of these synthesized events).

This change updates the report schema to reflect that certain
fields can be null. It also adds a spec test including an error
event, which requires the schema change in order to pass.
Merge pull request #2305 from joshcooper/issue/stable/PUP-1411-SSL_connect_timeout

(PUP-1411) Protect against SSL_connect errors
(PUP-1118) Add acceptance test for using directory envs

This checks that an environment that comes from the environmentdir
setting is usable as an environment.
(PUP-1118) Stop using Environment.new

Instead of creating environments directly, we need to go through the
configured environment loaders, otherwise environments can't come from
other places.
(PUP-1463) Enable puppet.service during upgrade if puppetagent.service was previously enabled
Merge remote-tracking branch 'upstream/stable'

* upstream/stable:
  (PUP-1411) Increase CLIENT_HELLO timeout
  (PUP-1411) Initialize OpenSSL before starting TCP connection
Merge pull request #2298 from mckern/add-el7-to-stable

Apply the RHEL7 work and merge it into stable
Merge branch 'stable'

Conflicts:
	ext/build_defaults.yaml
(PUP-1118) Fix rdoc1 specs to match changes to rdoc puppet_parser_core

PuppetParserCore was updated to pass environment, known_resource_types;
this just catches up the spec, which runs only on 1.8.7, to match the
changes.
Merge pull request #2269 from skottler/PUP-1463

(PUP-1463) Enable puppet.service during upgrade if puppetagent.service was previously enabled
(Maint) Remove dead port code

The port code has been commented out and unmaintained since 5d2f95 (~7
years ago).
Merge pull request #2308 from zaphod42/maint/master/remove-dead-port-code

(Maint) Remove dead port code
(Maint) Fix load order dependency

Running bundle exec rspec spec/unit/module_tool/install_directory_spec.rb
would fail because the Puppet::ModuleTool::InstallDirectory classes
referenced the Errors module without ensuring it was required.

This commit ensures that all of the module_tool leaf code requires its
parent first, and any code that they directly reference, e.g. open-uri