(#10354) added delete command to fix missing userdel flag in useradd provider
Fixes for #10915 and #11200 - user provider for AIX

The user provider on AIX fails to set the password for local users
using chpasswd.

This commit includes the code in ticket #11200 suggested by Josh
Cooper. It works in my environment (AIX 5.3 + 6.1).

chpasswd can also return 1 even on success; it's not clear if this is
by design, as the manpage doesn't mention it. The lack of output from
chpasswd indicates success; if there's a problem it dumps output to
stderr/stdout.
(#7285) Add spec for Augeas initialisation and file loading

Simple initialisaton tests with combinations of lens include paths, explicit
file/lens loading against a few example files.
(#13379) Add path of pluginsync'd lenses to Augeas load_path automatically

The path $libdir/augeas/lenses is added to the Augeas load_path initialisation
option automatically to support lenses being pluginsynced.  Lenses should be
added into the <module>/lib/augeas/lenses directory inside a module.

The load_path parameter has been expanded to support an array of paths as well
as a colon-separated list.
(#13880) Add openrc service provider for Gentoo and Funtoo

Gentoo uses openrc (at least since baselayout-2) to
start/stop/enable/disable services. This can be done with the following
commands

    /bin/rc-status   - show runlevels
    /sbin/rc-service - start/stop a service
    /sbin/rc-update  - enable/disable a service

The openrc provider was written as a replacement for the current gentoo
provider. The gentoo provider does just use the openrc commands to
enable/disable a service but it still calls the initscripts directly to
start a stop service. The gentoo provider does also have problems with
long service names (#5197).

The reason why this is a seperate provider: #5197 states that the
rc-service command was probably introduced when gentoo upgraded from
baselayout-1 to baselayout-2 (I wasn't really able to verify this)
so the openrc provider will not work on all gentoo systems.

It is also notable that the new openrc provider does not put any confines
on operatingsystem so the service provider may also be used on other
systems that use openrc (like the Gentoo fork "Funtoo")
(#13880) Add openrc spec - service with extreme long name

The old gentoo provider has some problems handling services with really
long names (#5197).

Add a tests to check the correct behaviour of the openrc provider. The
fake rc-status output was captured after creating a fake initscript in
/etc/init.d with a really long name
(#9160) Change logging facility to debug for not supported provider features
(#14599) Handle ENOTDIR in file type

If a file resource is used with a path where a component of path is not
a directory, the stat systemcall can raise the error Errno::ENOTDIR
which was not handled by the file type.

This can lead to the following error (if e.g /tmp/xx is a normal file)

    err: /Stage[main]//File[/tmp/xx/yy/zz/1]: Could not evaluate: Not a
    directory - /tmp/xx/yy/zz/1

Catch the error and return nil in the stat method like we do for absent
files or file where we do not have the permission to stat.

Puppet will still raise errors when trying to create such a file of
course like

    err: /Stage[main]//File[/etc/fstab/foo]/ensure: change from absent to
    file failed: Could not set 'file on ensure: Not a directory -
    /etc/fstab/foo at line

But something like

    puppet apply -ve 'file { "/etc/fstab/foo": ensure => absent}'

will now work without errors because `/etc/fstab/foo` is indeed absent.
(#13009) Compare scheduled task commands using backslashes

Previously, if the command for a scheduled task was specified using
forward slashes, puppet would always think the resource was out-of-sync.
This issue is that Windows does not preserve forward slashes, so the
*current* value always contains backslashes.

This commit munges forward slashes in the command to backslashes. It also
uses `File.expand_path`, because otherwise commands like the following in
the puppet language would be considered different:

    command => 'c:\\windows\\system32\\cmd.exe'
    command => 'c:\windows\system32\cmd.exe'
 (#13008) Allow scheduled task arguments to be specified

Previously, the `arguments` property of a `scheduled_task` resource
could not be specified as it would lead to a TypeError when we passed
the `should` array value to the task scheduler method that expected a
string.

Previously, scheduled tasks arguments could be specified as either a
string or an array. But if an array was specified it could only contain
a single element.

This commit requires that the arguments be specified as a
space-delimited string, e.g.  'arg1 arg2'.  It is not a breaking change,
because the ability to specify arguments never worked.
(#14749) Clear reference to invalid task after saving

Previously, running `puppet resource scheduled_task <name> ...` to
create a scheduled task would raise an exception. This would occur
because the provider's flush method calls `task.save`, which releases
the reference to the COM interface and sets it to nil. Then later the
`resource` application attempts to retrieve the state of the resource it
just flushed. This causes the win32-taskscheduler gem to raise an
exception because the underlying interface is nil.

This is not an issue when applying a manifest, because puppet doesn't
retrieve the state of the resource after it's been flushed. However,
when writing acceptance tests for the scheduled_task type using `puppet
resource scheduled_task` this bug occurred.

The `Win32::TaskScheduler#save` method should have probably been called
`close` since you can't perform additional operations on it, once it's
been closed. However, this is the gem, not puppet code, and the method
does say:

    Note that calling TaskScheduler#save also resets the
    TaskScheduler object so that there is no currently active task.

So whatever.

This commit simply changes the provider's flush method to clear the
`Win32::TaskScheduler` object after saving it, so that subsequent calls
to the `task` getter method will create a new `Win32::TaskScheduler`
instance.

This commit also adds acceptance tests that exercise things that were
previously broken in #13749, #13008, and #13009. The tests rely on the
ability to create scheduled_tasks using the `puppet resource
scheduled_task` style invocation, which this commit fixes.

The acceptance tests are more verbose than one would like because the
options to the `schtasks.exe` are different for before Vista, and
Vista and later.
(#14860) Fix puppet cert exit status on failures

Without this patch applied the following command errors out but does not
correctly set the exit status:

    puppet cert generate foo.bar.com --dns_alt_names foo,foo.bar.com

The error returned is:

    err: Could not call generate: CSR 'pe-internal-broker-test'
      contains subject alternative names (DNS:pe-centos6, \
      DNS:pe-centos6.puppetlabs.vm, DNS:pe-internal-broker-test, \
      DNS:stomp), which are disallowed. Use `puppet cert \
      --allow-dns-alt-names sign pe-internal-broker-test` to sign this \
      request.

However, the exit status is 0.

This is a problem because we need to easily detect if certificate
generation from the command line failed or succeeded.  The most natural
and expected way to check this is by looking at the exit status.

The root cause of the problem is that
Puppet::SSL::CertificateAuthority::InterFace#apply incorrectly catches
and masks the exception raised by the generate method because it simply
logs an error with Puppet.err and continues along happily.

This patch fixes the problem by re-raising the error produced by
generate, allowing the application controller to catch the error
appropriately and exit with the non-zero exit status.
(#14964) Don't fail if we can't unlink the Tempfile on Windows

Previously, if the exec resource created a process, e.g. start.exe, that
executed another process asynchronously, then the grandchild would inherit
the tempfile handle, preventing puppet from being able to unlink it. This
is not an issue on POSIX systems.

This commit changes the `wait_for_output` method to ignore Errno::EACCES
exceptions caused when closing and unlinking the stdout tempfile. The
behavior on POSIX systems is unchanged.
Fixed #14975 - Fixed incorrect help text in puppet doc application
Merge pull request #596 from domcleal/tickets/2.7.x/13379-aug-pluginsync

(#13379) Add path of pluginsync'd lenses to Augeas load_path automatically
(#14441) Require instrumentation indirections

Previously, the instrumentation faces were not requiring their
corresponding indirection, so the indirections were not getting
registered,
e.g. Puppet::Indirector::Indirection.instance(:instrumentation_data)
was nil.  This was causing `spec/integration/documentation_spec.rb` to
fail -- it was iterating across each face and trying to generate help,
but that failed because the indirection wasn't registered.  This issue
didn't show up earlier, because due to a separate issue, the tests
were not being executed.

This issue only occurs when using the instrumentation related classes
programmatically, but not when running the applications, e.g. `puppet
instrumentation_data` because the latter calls
`Puppet::Util::Instrumentation.init` early on in the application
lifecycle, and that requires all of the instrumentation code.

This commit changes each instrumentation-related face to require its
instrumentation indirection, e.g. Puppet::Face[:instrumentation_data]
requires `puppet/util/instrumentation/data`.

This commit doesn't address the overall issue with #14441 in that
Puppet::Util::Instrumentation.init` has to be invoked before it can be
used, so don't close the bug when this is merged.
Maint: Actually execute the tests on non-windows platforms

Previously, the tests were using conditional pending statements to
mark tests that don't pass on Windows:

  describe "group" do
    pending("porting to Windows", :if => ...) do
      it "should ..." do
        ...
      end
      it "should ..." do
        ...
      end
    end
  end

But this is not a valid use of conditional pending statements, and it
causes the examples within the pending block to be silently skipped.
Instead, the conditional pending statement needs to be within the
example:

  it "should ..." do
    pending("porting to Windows", :if => ...) do
      ...
    end
  end

In our case, we want to mark a set of examples as pending, so we use
an rspec exclude filter instead:

  describe "something", :unless => Puppet.features.microsoft_windows? do

Some tests now pass on Windows, using :file instead of :mount and the
instrumentation documentation, so I enabled them.
(#13489) Synchronously start and stop services

Previously, we were using the `win32-service` gem to start and stop
services.  It uses Win32 APIs to programmatically send start and stop
requests.  The actual service starts/stops asynchronously with respect
to the request.  As a result, when refreshing a service, puppet would
issue a stop request, immediately followed by a start request, and that
would race as the service would often still be running when the start
request occurred, leading to 'An instance of the service is already
running'.

This commit changes the windows service provider to use `net.exe` to
start and stop services.  This command will block until the service
start/stops, and returns 0 on success, making it easy to adapt to the
provider command pattern.  The one downside is that the exit codes don't
have the same resolution that we can get via the `sc.exe` or by calling
the Service Control Manager programmatically.  But that is not too
critical because we do capture the output of the `net.exe` command, e.g.
'The service name is invalid.' and include it in the exception message.
(#13489) Use let to memoize instance variables

Converted instance variables, e.g. @resource, to let helper methods to
reduce verbosity.
(#15027, #15028, #15029) Fix upstart version parsing

A leading space in the --version argument would confuse upstart, and the
version returned would not always be a semantic version, which caused the
upstart provider to fail. This commit updates the initctl call to remove the
leading space from the --version argument, and also replaces the implicit
SemVer comparisons with wrapper functions that call out to
Puppet::Util::Package.versioncmp to do version comparisons. It also fixes a
subtly broken regex to grab the full version string.