(#8193) Support new keytypes for ssh_authorized_key

Recent versions of openssh (at least openssh 5.8) support the following
keytypes in in the authorized_keys file: ecdsa-sha2-nistp256,
ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-dss or ssh-rsa.

Add support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 and
ecdsa-sha2-nistp521.
(#8193) Support new keytypes for sshkey

Recent versions of openssh (at least openssh 5.8) support the following
keytypes in in the authorized_keys file: ecdsa-sha2-nistp256,
ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-dss or ssh-rsa.

Add support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 and
ecdsa-sha2-nistp521.
(#8193) Add unit tests for new ssh keytypes

Add unit tests to prove that the ssh_authorized_key provider can parse
all different keytypes. This currently shows that the provider lacks
support for ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, and
ecdsa-sha2-nistp521 keys.
(#8193) Add support for new ssh keytypes in authorized_key provider

The provider now correctly detects lines that describe an
ecdsa-sha2-nistp256, ecdsa-sha2-nistp384 or ecdsa-sha2-nistp521 key.
(#11451) Fix improper use of "defined" in the duplicate declaration error

Duplicate resource declarations (including classes with the resource-like
class {'name':} syntax) were provoking the following error:

Duplicate definition: Class[Test] is already defined in file /tmp/test.pp at
line 9; cannot redefine at /tmp/test.pp:10 on node example.com

This is incorrect -- the problem is a duplicate declaration, not a duplicate
definition. I believe this is a holdover from our formerly sloppy use of the two
terms.

This commit fixes the error message, and renames several variables and methods
to match our current understanding of the terms "define" and "declare." Tests
are fixed as well.
Fix stage inheritance between multiple included classes

Commit 656eff8 introduced a regression whereby stages would only
propagate from a class to its direct descendants, and no further. This
means if a class A includes B which includes C, the stage specified for
class A would only be used for A and B, and would omit C.

This was due to a logic error around the recursive nature of class
evaluation. We would evaluate the outermost class, and while doing so,
would evaluate its children, and etc. The step after evaluate was to set
up the stage relationship, which would then happen in reverse order
(C and then B and then A) as the stack was unwound. This meant that C
would try to set its stage, see that it had no specified stage, and try
to use its parent's stage (B). B also had no specified stage,
so C fell back to main. The next step in the stack, however, was to set
B's stage, which would then be inherited from A.

The purpose for the breaking change was to move stage setup after
parameters were set, so that defaults could be used to set stage. So now
we move stage setup back a bit in processing, between parameter setup and
actual evaluation of the contained code (which is the step which will
eventually evaluate the children). This achieves the desired effect of
setting stages after parameters, but also correctly sets stages in
top-down order, allowing them to cascade naturally.

Included in this is a small change during compiler setup to add the
Settings class to the catalog *before* evaluate_code is called. This is
because evaluate_code will now add the class to the main stage, which
requires the resource know about its catalog. Since Settings is never
really executed on the agent in a meaningful way, adding it to stage
main has no practical effect, so this is a safe change.
(#12081) ensure user deletes respect managehome

When deleting a user with managehome set the documentation says the
provider should remove the user's home directory. This fixes the
pw provider to do that by adding the -r flag to the command.
(#12188) Better handling of PID file cleanup warnings.

Previously everyone who invoked the `unlock` method of our pid file code would
duplicate all the internal logic to issue a warning, but only if we tried and
failed to delete the PID file.

This seems redundant compared to just pushing that down to the code that
actually fails, which this commit does.

Along the way it helps ensure that we don't warn unnecessarily about PID file
deletion, and adds tests to validate that.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge branch 'bug/2.7.x/12188-pid-handling-warning-cleanup' into 2.7.x

* bug/2.7.x/12188-pid-handling-warning-cleanup:
  (#12188) Better handling of PID file cleanup warnings.
(#10064) Add the Puppet environment to reports

Previously the Puppet environment was not included in
the report output. Using the model of how configuration_version
was added to the reports the environment will now also be reported.

Puppet::Transaction::Report now takes three arguments:

* Kind of report
* Configuration version
* Environment

Tests for this have been added and existing tests updated.
(#12188) Handle Win32 as well as Unix in pidfile tests.

When I changed the testing for the PID file system I neglected to check that
Win32 would work; this makes sure the path used is absolute for the platform
the specs run on, fixing that problem.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #421 from daniel-pittman/bug/2.7.x/12188-pid-handling-warning-cleanup

Bug/2.7.x/12188 pid handling warning cleanup
(#12296) Test cycle detection on real Puppet::Type instances.

We have found a couple of places where the behaviour of the items tested, and
the behaviour of the real system, differ - because the tests were run over
simpler objects than the real Puppet::Type instances we work on in the field.

This moves from testing on fake things to testing on the real deal, which
gives us a much more solid basis to trust the tests.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Make `Puppet::Type` ordered.

Type instances have a reasonable natural order, which allows us to make them
Comparable.  This, in turn, makes any interaction where ordering is of
interest easier to deal with.

This implementation uses the string form of the resource as the basis for
comparison, which is a reasonable starting point from existing definitions of
ordering over resource instances.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Now that `Puppet::Type` is ordered, use that.

This eliminates the proxy sorting in the graph library, which was working
around the fact that Puppet::Type was not able to be ordered out of the box.

That makes the whole process significantly more robust.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Make `Puppet::Provider` ordered.

Like types, our providers have a natural internal order.  Exposing that allows
us to eliminate proxy sorting everywhere that it is done, and have more
uniform treatment of our types.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Use natural ordering of Puppet::Provider.

The module tool used to generate and sort by a proxy key for providers, when
detailing their content.  Instead, this can use the natural ordering of
providers previously introduced.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#12296) Acceptance test for cycle detection in graphs.

This adds a simple acceptance test that validates we detect and report cycles
in a catalog as we compile and try to execute it.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
(#11423) Better error when imported resources overlap.

When multiple nodes export a resource with a duplicate type and title, and you
import both, the error message misleadingly tells you that this was a *local*
duplication.

This improves the error message to cover all the bases, which is suboptimal -
it should tell you where the duplicate comes from - but at least doesn't lead
to a wild goose hunt for the *local* duplicate that doesn't exist.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge branch 'bug/2.7.x/11423-better-collector-error-message' into 2.7.x

* bug/2.7.x/11423-better-collector-error-message:
  (#11423) Better error when imported resources overlap.