init: Check if running if not configured to start.

The reasoning for this is explained in:
https://projects.puppetlabs.com/issues/23033

Currently the init-script does not actually check if we're running and
return accordingly when status is called if the puppet master is not
configured to start.

This causes it to always return 0, meaning we're actually running
regardless of if that is the case.
Maint: Reformat docs for Augeas type's "changes" attribute

I'm trying to get DL elements out of the docs, and this fragment works better as
a more compact list anyway.
Maint: Reformat indirection reference to use H4s instead of DLs for termini

A long time ago, I shortsightedly decided to use the definition list Markdown
extension in some of our docs. Time and the renderer ecosystem haven't been kind
to that syntax, so we need to get away from them if we want to be able to switch
relatively freely between various MD processors.

This commit removes them from the last embedded documentation that we still use.
The old-style type reference still uses them, but since we've stopped relying on
it and moved to our own implementation, that should be fine.
(#22925) Fall back to cached catalog if we can't connect to the master

Prior to commit 093a0745b4, puppet would attempt to download a catalog, and if
that failed, it would apply a previously cached catalog. Note this
behavior is controlled by the `usecacheonfailure` setting, which is
disabled when using `--test`.

In commit 093a0745b4, the ENC was made authoritative for specifying node
environment. In doing so, the agent makes a REST call to the master for
its Node object, and then reads the environment from it.

However, the call is made in a begin/rescue block that only catches
Puppet::Error and Net::HTTPErrors, but not errors like
Errno::ECONNREFUSED, etc.

This commit ensures that any standard error will be caught when
retrieving the node's environment, as is done when retrieving the
catalog. If we fail to obtain the node's environment, we warn, and
continue trying to apply the catalog.

This commit does not try to fix consistency issues between the node and
catalog requests. For example, the node request could fail, resulting in
the agent requesting a catalog using its agent-configured environment.
The catalog request could succeed, resulting in the agent applying a
catalog from an environment that doesn't match what the ENC thinks it
should be.
(#23074) Add reinventory command to puppet cert

This adds a reinventory command to the puppet cert application.

Further work on this is to refactor the use of the #apply method
found in Puppet::SSL::CertificateAuthority as it delegates to
a subclass called Interface to do the work. This is all an application
concern and it is confusing with the back and forth between the classes
"the cert application", the CA and its Interface.
(#23074) Add text to warn that master should be inactive for reinventory.
(#23074) Cleanup logic

This makes a couple of the methods in the CertificateAuthority and
related Interface classes easier to read / understand.
(#23074) Remove header in inventory.txt when regenerating

The regenerate inventory wrote a header that was not there in the
original file.
(#23074) Make cert inventory not rebuild inventory.txt when adding

There is a race condition that requires protection if the inventory
performs rebuild of a missing inventory.txt file when adding a cert.
Without the protection the inventory may end up with double entries or
missing entries, and with the protection the processing of cert requests
become serialized over all processors creating a performance problem.

This change simply appends to the inventory.txt - if the file does not
exists, it is atomically created.

A users that wants to recreate the inventory should do so with the
command `puppet cert reinventory` which may be executed on an
inactive system.
(#23074) Refactor cert application's use of cert authority's interface

The code was difficult to understand as the cert application called
the apply function on the CertAuthority, which in turned created an
instance of the Interface class, which in turn called back into the
ca. As this construct was only used by the cert application, the ca's
apply method was moved to the cert application.

It is now more clear that the application interacts with the ca via
an instance of its Interface class.
(#23074) Remove overly stubbed tests

There were several tests attempting to test the cert application,
the CertificateAuthority and its interface, as well as the inventory
handling by use of excessive stubbing that prevents any real code from
being tested.

The failing overly mocked tests have been removed. Their value was
questionable to begin with.
Merge pull request #2031 from joshcooper/ticket/master/22925-cached-catalogs

(#22925) Fall back to cached catalog if we can't connect to the master
(#23081) Ensure that errors from insync? create proper events
(Maint) Reorder and reduce scope of harness

This makes non-public methods explicitly private. It also reorders the
methods to read in a manner where the top is the public and highest
level, and it becomes more low level as we move down the file.
(#23801) Add unit tests for insync? raising StandardError or Exception
(maint) Remove large spec test block whose benefits were unclear.

This changes removes a large block of unit tests, comprising
1296 individual tests built up via 8 nested 'each' loops. Why
remove so many tests?

First, in the course of refactoring for #23081 we triggered
test failures in this block only when we also triggered a test
failure elsewhere, and conversely, it didn't trigger failures
where other individual tests did register a useful failure.

Second, several people have stared at this unit test block
and not been able to figure out what it is uniquely testing.

So in short the value of this test block is not clear, so we're
removing it.  Of course, if we hit future gaps in unit test coverage,
we'll add tests back in to cover gaps.
(maint) Remove an unimplemented test and fix up some comments.
(#23085) Ensure old puppet agents get properly stopped when upgrading from 2.6 or early to 2.7 or later
Merge pull request #2036 from kylog/issue/23081/report-property-event-for-insync-exceptions

Issue/23081/report property event for insync exceptions
(Maint) Small cleanups

Just a simple typo fix and re-expanding some blocks to make adding in
debugging easier at a later date.(Maint) Small cleanups