Remove .rspec from source

The only thing this file did was enable color.  This is a personal
preference, as is --fail-fast while using autotest.  It's a problem that
personal preferences can't be expressed without making the source dirty.
This patch fixes the problem my removing and ignoring the rspec file.

This patch also fixes a file not found exception in the watchr script
when the .rspec file does not exist.
(maint) Add pry development gem dependency

This is just a development debugging tool.
Add rake collect:ec2_metadata task

Facter does not provide the means to easily collect example fixture data
from a running EC2 instance.  This is a problem because it is difficult
to develop robust facts using the EC2 metadata server without example
fixtures to write specification tests against.

This also makes TDD/BDD difficult when running on a Mac laptop outside
of the EC2 environment.

This patch is enables TDD/BDD of EC2 facts by providing example
responses from the metadata server API as YAML fixture data.
(#7559) Add Facter::Util::EC2.with_metadata_server method

Without this patch Facter has no clear way to define the EC2 related
facts in a robust and reliable manner.  This is a problem because Facter
needs to run as robustly on nodes that are inside of EC2 as it does on
nodes that are outside of EC2.

The root cause of the problem is that we have no way to introspect the
system to determine if we're on EC2 or not without making a network call
to the metadata server. [1]  This means that either non-EC2 nodes will
suffer a timeout trying to connect to a non-existent metadata server or
EC2 nodes will suffer from facts not being defined.

This patch addresses the problem by adding a new utility method with the
following behavior.  A block is accepted and will be executed only under
the following conditions.  The block should execute whatever code is
necessary to define the EC2 facts themselves.

1: Do not execute if the virtual fact is not "xenu"
2: Do not execute the metadata server does not respond in 100ms after
three consecutive attempts.

[1] https://forums.aws.amazon.com/thread.jspa?threadID=62617
(#7559) Try to define EC2 facts if virtual => xenu

Without this patch the EC2 facts use a number of methods to determine if
they're running on openstack, Amazon EC2, eucalyptus, and others.  These
methods have proved to be lacking robustness.

This is a problem because Facter fails to define facts even when a
Metadata server is available.

This patch addresses the problem by changing the behavior of deciding
when to define the dynamic EC2 facts.  The
Facter::Util::EC2.with_metadata_server method is used with a 50ms
timeout over three consecutive retries.

With this patch applied the EC2 metadata and userdata facts will be
defined whenever the node is has a virtual fact value of "xenu" and
there is a metadata data server available at http://169.254.169.254

This patch also removes the `userdata` and `metadata` methods that were
previous defined as instance methods on the base Object class.
Merge branch 'ec2_vpc_7559'

* ec2_vpc_7559:
  (#7559) Try to define EC2 facts if virtual => xenu
  (#7559) Add Facter::Util::EC2.with_metadata_server method
  Add rake collect:ec2_metadata task
  (maint) Add pry development gem dependency
  Remove .rspec from source
Avoid external command for reading filesystem type list.

This eliminates the use of cat in favour of plain and ordinary read; despite
the brief RedHat reintroduction of the kernel bug when using select on files
in /proc, this isn't worth working around in some-but-not-all places.

It also eliminates most of the lines while still having the same effect,
making the code much cleaner.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Faster, sysfs based interface listing for Linux.

This reimplements "obtain a list of all interfaces" to use sysfs, where
available, since it is significantly faster and cheaper than doing the same
through forking and executing an external command.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Conflicts:
	spec/unit/util/ip_spec.rb
Use simpler DSL for declaring external commands.

When a fact is simply the result of running an external command, a block isn't
needed - just the command string.

This changes a bunch of facts to use that shorter, simpler form as an example
to those who follow about how they should be declared.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Conflicts:
	lib/facter/physicalprocessorcount.rb
	lib/facter/processor.rb
Avoid using cat to read files.

...because, seriously, UUOC is no laughing matter.

Don't condone cat abuse.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>

Conflicts:
	lib/facter/operatingsystemrelease.rb
Trivial whitespace cleanup.

Literally, one misplaced space gone.

Signed-off-by: Daniel Pittman <daniel@puppetlabs.com>
Fixup failures after addressing merge conflicts
Merge branch 'misc-exec-to-ruby-transformations'

* misc-exec-to-ruby-transformations:
  Fixup failures after addressing merge conflicts
  Trivial whitespace cleanup.
  Avoid using cat to read files.
  Use simpler DSL for declaring external commands.
  Faster, sysfs based interface listing for Linux.
  Avoid external command for reading filesystem type list.
Maint: Ensure we don't read from /sys/class/net

Previously, the ip_spec test relied on the /sys/class/net file not
existing, so that it would flow into the HP-UX logic. But when the test
is executed on linux, the file exists, so the test short-circuits and
never evaluate the HP-UX part.

Since the facter tests are so fragile, I `expect` more than `stub` to
ensure the code takes the route I'm trying to test.
(maint) Fix physicalprocessorcount with multiple cores

Without this patch applied the physicalprocessorcount fact reports the
wrong number of processors.  Instead of reporting the number of physical
processing units, it reports the number of cores.  This patch addresses
the problem by changing the behavior to count only the number of unique
processor identities as suggested by Stefan Schulte.

We didn't catch this issue while rebasing GH-266 in GH-388 because this
behavior had no specified expectations.  This patch adds an example of
the expected behavior when there are multiple cores per processor.
Add specs for physicalprocessorcount

Add test to check if multicore processors are handled correctly when
we only want to count physical processors
Merge branch 'ticket/master/fix_physical_processor_count'

* ticket/master/fix_physical_processor_count:
  Add specs for physicalprocessorcount
  (maint) Fix physicalprocessorcount with multiple cores
(#13396) Unify ifconfig usage and lookup ifconfig path to fix support for recent net-tools

Without this patch applied linux systems with recent net-tools loose
support for ipaddress,macaddress and other network related facts.
This is due to a path change from /sbin/ifconfig to /bin/ifconfig.
This patch fixes this issue by unifying the lookup and execution of
ifconfig and testing where the ifconfig binary is installed.
Merge branch 'backport-gh-386' into 1.6.x
Merge branch '1.6.x' into 1.7.x