[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35

test branch puppet-dev at googlegroups.com
Wed Jul 14 10:34:40 UTC 2010


The following commit has been merged in the upstream branch:
commit 8b127b185171c516b0d3ab526e0f7606063582bb
Author: Nick Lewis <nick at puppetlabs.com>
Date:   Fri Jun 18 14:19:38 2010 -0700

    [#3388] Setting host_aliases from [] to [] no longer results in any changes
    
    The message was "host_aliases changed from 'absent' to ''". When reading from
    the hosts file, a host without aliases was considered to have "absent"
    host_aliases. The host_aliases list is now considered to be present but empty
    if it is absent.

diff --git a/lib/puppet/provider/host/parsed.rb b/lib/puppet/provider/host/parsed.rb
index f3e7630..d69dcbe 100644
--- a/lib/puppet/provider/host/parsed.rb
+++ b/lib/puppet/provider/host/parsed.rb
@@ -25,7 +25,9 @@ Puppet::Type.type(:host).provide(:parsed,
             hash[:ip] = $1
             hash[:name] = $2
 
-            unless line == ""
+            if line.empty?
+                hash[:host_aliases] = []
+            else
                 line.sub!(/\s*/, '')
                 line.sub!(/^([^#]+)\s*/) do |value|
                     aliases = $1
@@ -41,7 +43,7 @@ Puppet::Type.type(:host).provide(:parsed,
         end
 
         if hash[:host_aliases] == ""
-            hash.delete(:host_aliases)
+            hash[:host_aliases] = []
         end
 
         return hash
@@ -58,7 +60,7 @@ Puppet::Type.type(:host).provide(:parsed,
 
         str = "%s\t%s" % [hash[:ip], hash[:name]]
 
-        if hash.include? :host_aliases
+        if hash.include? :host_aliases and !hash[:host_aliases].empty?
             if hash[:host_aliases].is_a? Array
                 str += "\t%s" % hash[:host_aliases].join("\t")
             else
diff --git a/test/ral/providers/host/parsed.rb b/test/ral/providers/host/parsed.rb
index ce70f5c..8397612 100755
--- a/test/ral/providers/host/parsed.rb
+++ b/test/ral/providers/host/parsed.rb
@@ -106,7 +106,7 @@ class TestParsedHostProvider < Test::Unit::TestCase
             {:record_type => :parsed, :name => "myhost", :ip => "192.168.43.56", :host_aliases => %w{another host}},
             {:record_type => :blank, :line => "    "},
             {:record_type => :comment, :line => "# another comment"},
-            {:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57"}
+            {:record_type => :parsed, :name => "anotherhost", :ip => "192.168.43.57", :host_aliases => []}
         ], instances)
 
         newtext = nil

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list