summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Cooper <josh@puppetlabs.com>2011-07-29 13:30:15 -0700
committerJacob Helwig <jacob@puppetlabs.com>2011-08-19 13:52:58 -0700
commit7259e1e5877b81dc5fd9b6ff090a4cccfc37c2f4 (patch)
treef8cac3bfd6c3142c4fd9619e1cdc463a22a2a9de
parent328eaa2f7fd07ac7059e62d30064ef4b70f1f89f (diff)
downloadpuppet-7259e1e5877b81dc5fd9b6ff090a4cccfc37c2f4.tar.gz
puppet-7259e1e5877b81dc5fd9b6ff090a4cccfc37c2f4.tar.xz
puppet-7259e1e5877b81dc5fd9b6ff090a4cccfc37c2f4.zip
(#8644) Host provider on Windows
The host provider did not work on Windows because it didn't know where to find its hosts file. The provider now uses Win32::Resolv, which is part of the standard ruby library, to find it. Several host type/provider spec tests were marked as fails_on_windows, but now that the provider is working, I removed the tag from those tests, and verified that the tests now pass. There are two tests in resources_spec that fail because the user and exec providers are not supported on Windows yet, so those tests are marked as fails_on_windows. Reviewed-by: Pieter van de Bruggen <pieter@puppetlabs.com> (cherry picked from commit 82c6b3cb41397c989c011cf767066bcf1e403db2)
-rw-r--r--lib/puppet/provider/host/parsed.rb3
-rwxr-xr-xspec/unit/provider/host/parsed_spec.rb2
-rwxr-xr-xspec/unit/type/host_spec.rb2
-rwxr-xr-xspec/unit/type/resources_spec.rb6
4 files changed, 8 insertions, 5 deletions
diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb
index 2ba01a41c..1a2bdb460 100644
--- a/lib/puppet/provider/host/parsed.rb
+++ b/lib/puppet/provider/host/parsed.rb
@@ -3,6 +3,9 @@ require 'puppet/provider/parsedfile'
hosts = nil
case Facter.value(:operatingsystem)
when "Solaris"; hosts = "/etc/inet/hosts"
+when "windows"
+ require 'win32/resolv'
+ hosts = Win32::Resolv.get_hosts_path
else
hosts = "/etc/hosts"
end
diff --git a/spec/unit/provider/host/parsed_spec.rb b/spec/unit/provider/host/parsed_spec.rb
index fa41d82e5..9cb5890cc 100755
--- a/spec/unit/provider/host/parsed_spec.rb
+++ b/spec/unit/provider/host/parsed_spec.rb
@@ -6,7 +6,7 @@ require 'puppet_spec/files'
provider_class = Puppet::Type.type(:host).provider(:parsed)
-describe provider_class, :fails_on_windows => true do
+describe provider_class do
include PuppetSpec::Files
before do
diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb
index 145fb27ab..602c428af 100755
--- a/spec/unit/type/host_spec.rb
+++ b/spec/unit/type/host_spec.rb
@@ -34,7 +34,7 @@ describe host do
end
- describe "when validating values", :fails_on_windows => true do
+ describe "when validating values" do
it "should support present as a value for ensure" do
proc { @class.new(:name => "foo", :ensure => :present) }.should_not raise_error
end
diff --git a/spec/unit/type/resources_spec.rb b/spec/unit/type/resources_spec.rb
index 5e9396b24..f596968d3 100755
--- a/spec/unit/type/resources_spec.rb
+++ b/spec/unit/type/resources_spec.rb
@@ -21,7 +21,7 @@ describe resources do
end
end
- describe "#generate", :fails_on_windows => true do
+ describe "#generate" do
before do
@host1 = Puppet::Type.type(:host).new(:name => 'localhost', :ip => '127.0.0.1')
@catalog = Puppet::Resource::Catalog.new
@@ -51,7 +51,7 @@ describe resources do
@resources.generate.collect { |r| r.ref }.should_not include(@host1.ref)
end
- it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true do
+ it "should not include the skipped users", :'fails_on_ruby_1.9.2' => true, :fails_on_windows => true do
res = Puppet::Type.type(:resources).new :name => :user, :purge => true
res.catalog = Puppet::Resource::Catalog.new
@@ -72,7 +72,7 @@ describe resources do
end
end
- describe "when the instance's do not have an ensure property" do
+ describe "when the instance's do not have an ensure property", :fails_on_windows => true do
it "should not be included in the generated resources" do
@no_ensure_resource = Puppet::Type.type(:exec).new(:name => '/usr/bin/env echo')
Puppet::Type.type(:host).stubs(:instances).returns [@no_ensure_resource]