(#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.
(#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.
(#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.
(#12268) String#each is not available in Ruby 1.9

In earlier versions of Ruby, String#each and String#each_line were identical.
In the 1.9 series the former was dropped; this audits the code for places that
should by using `each_line` instead.

This includes some fixes for tests that had very specific stubs around reading
file content, where the expectation - but not the test - was broken by
changing the method we invoke.

It also fixes a stub over `execpipe` that had a different return type to the
actual method, but which happened to work because `each` was defined on both
Array and String in earlier versions.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Merge pull request #419 from nicklewis/ticket/2.7.x/10064

Ticket/2.7.x/10064 Add environment to reports
(#12329) Allow faces when_rendering blocks to take options

When rendering for face actions was implemented it was assumed that all
the options that an action took would go toward determining the data
that the when_invoked block returned, and the rendering would make
decisions based on that data's structure.  However, there are times when
the data returned may be the same even with different options, and the
option will determine how it's rendered.

For example, the `module list` action has a --tree option that will
display the installed modules in a tree view based on dependencies. The
`module search` action will be able to highlight the word that was
searched for in the results.

This commit allows the when_rendering blocks to optionally add options
and arguments along with the invoked result.  I made the options and
arguments optional since most when_rendering blocks won't need the
them, and having them show up in the block declaration when not used
is confusing.  This also means that all faces previously written don't
need changes and this change is backward compatible.
Revert "Merge pull request #396 from jeffmccune/feature/2.7.x/12088_windows_build_tasks"

This reverts commit dd6bef5446a3ce892b503ac19830f810791560ad, reversing
changes made to 586074aca8dd49843ebfb9f160b408b7907cf886.

We've decided to back this out because the windows build system packages
Ruby and Facter in addition to Puppet.  Therefore, the windows build
system should be in a separate repository.

Please see http://projects.puppetlabs.com/issues/11205 for the location
of the new repository.