Revert "(#11423) Clearer error message about duplicate imported resources."

This reverts commit e8e1f577ba091203b05b4a8279aadd8c55a65fe7.

This was committed directly rather than as a pull request because I misread
the GitHub "online code editor" button, and it didn't behave the way I
expected.

I intended a pull request, rather than a commit, and will reissue this the
right way.  Sorry. :(
Merge pull request #278 from nfagerlund/ticket/2.7.x/11404-type-reference-indentation

Ticket/2.7.x/11404 type reference indentation
(#7428) Fix option parsing for ruby 1.9 in cert application

In Ruby 1.9 block arity is strictly enforced. This changes options created
using blocks to all take one argument. The OptionParser library handles this
correctly even if an option doesn't take arguments (giving an argument of true
if the block takes an argument).
Merge pull request #279 from pcarlisle/tickets/2.7.x/7428-cert-ruby-1.9.2-issues

(#7428) Fix option parsing for ruby 1.9 in cert application
(#10586) Don't copy owner and group when sourcing files from master

Previously, puppet on Windows was not able to source files from the
master, because it was attempting to translate the uid/gid from
the Unix master into a Windows account, and obviously failing.

This commit skips the owner and group properties when copying them
from non-local sources, i.e. sources whose URIs have a 'puppet'
scheme.

If the source comes from a local source, then puppet behaves the same
as it did previously, it copies the owner and group if the source
volume supports Windows ACLs, e.g. C:/, samba mapped drives, or uses
default values if the volume does not, e.g. VMware shared drives.
(#11408) Fix fact and plugin sync on Windows

Previously, fact and pluginsync were broken on Windows, because it was
defaulting the owner and group to Process.uid/gid, and then failing to
translate them into Windows SIDs.

This commit changes the default file owner to the current user name,
and the default file group to Nobody, which is the group that Windows
typically applies to newly created files.
Merge pull request #281 from joshcooper/ticket/2.7.x/11408-fact-plugin-sync

(#11408) Fix fact and plugin sync on Windows
Merge pull request #280 from joshcooper/ticket/2.7.x/10586-file-sourcing-from-master

(#10586) Don't copy owner and group on Windows when sourcing from master
(#7106) Obey specified owner, group, and permissions for last run summary file

When writing the last run summary (puppet settings lastrunfile), we
now enforce any specified mode.  The default permissions have also
been changed to 0644.  This can be changed in puppet.conf:

  [agent]
  ...
  lastrunfile = /tmp/lastrun.yml { mode=0664 }
  ...

While the owner and group can be specified, the only choices that work
at this time are root, and the service user/group.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Signed-off-by: Jacob Helwig <jacob@puppetlabs.com>
Merge branch 'tickets/2.7.x/7106-last-run-summary-permissions' into 2.7.x

* tickets/2.7.x/7106-last-run-summary-permissions:
  (#7106) Obey specified owner, group, and permissions for last run summary file
Account for Windows file mode translation for lastrunfile

Windows file modes do not directly translate to POSIX file modes, so
we can't use the same file mode on Windows to check that setting the
mode worked correctly.
(#11414) Save/execute changes on versions of Augeas < 0.3.6

Versions of Augeas prior to 0.3.6 didn't report their version number, so a
fallback of executing changes once in need_to_run? and again in execute_changes
is performed.  Otherwise a save is done in need_to_run? and this is re-used in
execute_changes.

The /augeas/events/saved node is used to tell whether the latter optimisation
happened, but the return value of #match wasn't tested correctly (it's an empty
array).
Merge pull request #282 from jhelwig/last-run-summary-permissions-on-windows

Last run summary permissions on windows
(#11414) Test Augeas versions correctly with versioncmp

The release of Augeas 0.10.0 broke simplistic version comparisons with the >=
operator, so now use versioncmp.
Merge pull request #284 from MaxMartin/ticket/2.7.x/10109-composite-namevars

Ticket/2.7.x/10109 composite namevars
(#8119) Write reports to a temporary file and move them into place

When writing reports, there is a window in between opening and writing to the
report file when the report file exists as an empty file. This makes writing
report processors a little annoying as they have to deal with this case. This
writes the report into a temporary file then renames it to the report file.

Signed-off-by: Patrick Carlisle <patrick@puppetlabs.com>
Merge branch 'tickets/2.7.x/8119' into 2.7.x

* tickets/2.7.x/8119:
  (#8119) Write reports to a temporary file and move them into place
Instrumentation foundation layer

This is the base of the instrumentation layer.
The idea is to allow instrumentation of code blocks.
Each time this code is executed an event is fired to some event
listeners that in turn can do whatever is needed to perform the instrumentation.

This patch adds:
 * code instrumentation calls
 * the listener system

Listeners are added by adding a file to puppet/util/instrumentation/listeners
containing:

Puppet::Util::Instrumentation.new_listener(:my_instrumentation, pattern) do

  def notify(label, event, data)
    ... do something for data...
  end
end

It is possible to use a "pattern". The listener will be notified only
if the pattern match the label of the event.
The pattern can be a symbol, a string or a regex.
If no pattern is provided, then the listener will be notified for every
event.

The notify method will be called before and after the insturmented code
is executed, with respectively an event of :start and then :stop.

This class is thread-safe.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Add indirection (REST usable) to manipulate instrumentation

This adds two REST API:
* /instrumentation_listener(_search)/<instrumentation_name>

GET /instrumentation_listener/<instrumentation_name>
Gives details about a given instrumentation listener

GET /instrumentation_listener_search/unused
Lists all instrumentation listeners loaded in the system

PUT /instrumentation_listener/name
Allows to enable or disable a given instrumentation listener (supports
only pson). The body should be {"name":"instrumentation_name","pattern":<pattern>,"enabled":true}

DELETE /instrumentation_listener/<instrumentation_name>
This fully unsubscribe a listener

* /instrumentation_data/<instrumentation_name>
Only GET is supported. This returns the accumulated data of the given
instrumentation name if the listener supports data aggregation.
This is the only way so far to get access to the instrumentation data.
The data format is specific to the given listener.

Note: actual default auth.conf doesn't allow to interact with these
two indirections.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Add a way to add probe to puppet code

This patch contains a module (Instrumentable) that can be mixed in
various puppet classes to help define probes.

To add a probe for a given method, it is just a matter of using
the Instrumentable probe method:

class MyClass
  extend Instrumentable

  probe :thismethod
  def thismethod(arg)
  ...
  end
end

Used with no options the probe is created with a default label of
the instrumented method name and an empty dataset.

It is possible to set a given label, or use a proc as the label, in which
case the label will be the result of the evaluation of the said proc.

For instance:

class MyClass
  extend Instrumentable

  probe :thismethod, :label => Proc.new { |parent,args| args[0] }

  def thismethod(arg1, arg2)
  end
end
In this last example, the label will be the value of "arg1".
The parent argument of the :label block will contain the "self"
value of the instrumented method

When the thismethod will be called, it will in turn call the instrumentation
layer with the given label and data.

Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>