17284016 nis, ldap, and dns refreshed on every Puppet run
authorVirginia Wray <virginia.wray@oracle.com>
Mon, 12 Aug 2013 11:30:04 -0700
changeset 1427 0b76fc564cd2
parent 1426 47002a1da407
child 1428 94d2b78b3e05
17284016 nis, ldap, and dns refreshed on every Puppet run 17277145 nsswitch provider object error and missing parameter 17271383 NIS provider is not updating domainname property 17270555 NIS provider returns an error when attempting to set securenets parameter
components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb
components/puppet/files/solaris/lib/puppet/provider/nsswitch/solaris.rb
components/puppet/files/solaris/lib/puppet/type/dns.rb
components/puppet/files/solaris/lib/puppet/type/ldap.rb
components/puppet/files/solaris/lib/puppet/type/nis.rb
components/puppet/files/solaris/lib/puppet/type/nsswitch.rb
--- a/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/ldap/solaris.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -32,6 +32,11 @@
     class << self; attr_accessor :ldap_fmri end
     @@ldap_fmri = "svc:/network/ldap/client"
 
+    def initialize(resource)
+        super
+        @refresh_needed = false
+    end
+
     def self.instances
         if Process.euid != 0
             return []
@@ -50,16 +55,11 @@
             end
 
             pg, prop = fullprop.split("/")
-
-            # handle the profile name differently as it's not in validprops
-            if prop == "profile"
-                props[:name] = value
-            else
-                props[prop] = value if validprops.include? prop.to_sym
-            end
+            props[prop] = value if validprops.include? prop.to_sym
         end
         props[:bind_passwd] = svcprop("-p", "cred/bind_passwd",
                                       "svc:/network/ldap/client").strip
+        props[:name] = "current"
         return Array new(props)
     end
 
@@ -91,6 +91,7 @@
                     svccfg("-s", @@ldap_fmri, "setprop",
                            pg + "/" + field.to_s, "=", should.to_s)
                 end
+                @refresh_needed = true
             rescue => detail
                 raise Puppet::Error,
                     "Unable to set #{field.to_s} to #{should.inspect}\n"
@@ -100,10 +101,8 @@
     end
 
     def flush
-        # the namevar is a param and will never get set by the setters defined
-        # above.  It must always be specified, so set it here.
-        svccfg("-s", @@ldap_fmri, "setprop", "config/profile", "=",
-               @resource[:name])
-        svccfg("-s", @@ldap_fmri, "refresh")
+        if @refresh_needed == true
+            svccfg("-s", @@ldap_fmri, "refresh")
+        end
     end
 end
--- a/components/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/nis/solaris.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -33,6 +33,12 @@
     @@client_fmri = "svc:/network/nis/client"
     @@domain_fmri = "svc:/network/nis/domain"
 
+    def initialize(value={})
+        super(value)
+        @client_refresh = false
+        @domain_refresh = false
+    end
+
     def self.instances
         props = {}
         validprops = Puppet::Type.type(:nis).validproperties
@@ -49,15 +55,10 @@
                 end
 
                 pg, prop = fullprop.split("/")
-
-                # handle the domainname differently as it's not in validprops
-                if prop == "domainname"
-                    props[:name] = value
-                else
-                    props[prop] = value if validprops.include? prop.to_sym
-                end
+                props[prop] = value if validprops.include? prop.to_sym
             end
         end
+        props[:name] = "current"
         return Array new(props)
     end
 
@@ -81,6 +82,7 @@
                     "Unable to set #{field.to_s} to #{should.inspect}\n"
                     "#{detail}\n"
             end
+            @client_refresh = true
         end
     end
 
@@ -114,11 +116,16 @@
                     "Unable to set #{field.to_s} to #{should.inspect}\n"
                     "#{detail}\n"
             end
+            @domain_refresh = true
         end
     end
 
     def flush
-        svccfg("-s", @@domain_fmri, "refresh")
-        svccfg("-s", @@client_fmri, "refresh")
+        if @domain_refresh == true
+            svccfg("-s", @@domain_fmri, "refresh")
+        end
+        if @client_refresh == true
+            svccfg("-s", @@client_fmri, "refresh")
+        end
     end
 end
--- a/components/puppet/files/solaris/lib/puppet/provider/nsswitch/solaris.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/provider/nsswitch/solaris.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -34,7 +34,7 @@
 
     def self.instances
         props = {}
-        svcprop("-p", "config", @@frmi).split("\n").collect do |line|
+        svcprop("-p", "config", @@nsswitch_fmri).split("\n").collect do |line|
             fullprop, type, value = line.split(" ", 2)
             pg, prop = fullprop.split("/")
             props[prop] = value \
--- a/components/puppet/files/solaris/lib/puppet/type/dns.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/dns.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -44,9 +44,13 @@
               3 IP addresses may be specified.  Specify multiple IP addresses
               as an array"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
 
         def insync?(is)
@@ -78,9 +82,13 @@
               entries may be specified.  Specify multiple search entries as an
               array."
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
 
         def insync?(is)
@@ -99,9 +107,13 @@
               be specified in IP 'slash notation'.  A maximum of 10 sortlist
               entries may be specified.  Specify multiple entries as an array."
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
 
         def insync?(is)
@@ -129,9 +141,13 @@
               no-check-names, inet6.  For values with 'n', specify 'n' as an
               integer.  Specify multiple options as an array."
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
 
         def insync?(is)
--- a/components/puppet/files/solaris/lib/puppet/type/ldap.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/ldap.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -48,8 +48,18 @@
     @doc = "Manage the configuration of the LDAP client for Oracle Solaris"
 
     newparam(:name) do
+        desc "The symbolic name for the LDAP client settings to use.  This name
+              is used for human reference only."
+        isnamevar
+    end
+
+    newproperty(:profile) do
         desc "The LDAP profile name"
-        isnamevar
+        class << self
+            attr_accessor :pg
+        end
+        self.pg = "config"
+        desc "The LDAP profile name"
     end
 
     newproperty(:server_list, :parent => Puppet::Property::List) do
@@ -61,11 +71,15 @@
         end
         self.pg = "config"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -90,11 +104,15 @@
         end
         self.pg = "config"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -140,11 +158,15 @@
         end
         self.pg = "config"
         
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -214,11 +236,15 @@
         end
         self.pg = "config"
         
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -240,11 +266,15 @@
         end
         self.pg = "config"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -276,11 +306,15 @@
         end
         self.pg = "config"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
@@ -301,11 +335,15 @@
         end
         self.pg = "cred"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
-
+        
         def insync?(is)
             is = [] if is == :absent or is.nil?
             is.sort == self.should.sort
--- a/components/puppet/files/solaris/lib/puppet/type/nis.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/nis.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -38,18 +38,27 @@
 Puppet::Type.newtype(:nis) do
     @doc = "Manage the configuration of the NIS client for Oracle Solaris"
 
-    newparam(:domainname) do
+    newparam(:name) do
+       desc "The symbolic name for the NIS domain and client settings to use.
+              This name is used for human reference only."
+        isnamevar
+    end
+
+    newproperty(:domainname) do
         desc "The NIS domainname"
-        isnamevar
     end
 
     newproperty(:ypservers, :parent => Puppet::Property::List) do
         desc "The hosts or IP addresses to use as NIS servers.  Specify
               multiple entries as an array"
 
-        # ensure should remains an array
+        # ensure should remains an array as long as there's more than 1 entry
         def should
-            @should
+            if @should.length == 1
+                @should.to_s
+            else
+                @should
+            end
         end
 
         def insync?(is)
@@ -73,46 +82,11 @@
         end
     end
 
-    newproperty(:securenets, :parent => Puppet::Property::List) do
-        desc "Entries for /var/yp/securenets.  Each entry must be a 2 element
-              array.  The first element must be either a host or a netmask.
+    newproperty(:securenets) do
+        desc "Entries for /var/yp/securenets.  Each entry must be a hash.
+              The first element in the hash is either a host or a netmask.
               The second element must be an IP network address.  Specify
-              multiple entires as an array of arrays"
-
-        # ensure should remains an array
-        def should
-            @should
-        end
-
-        def insync?(is)
-            is = [] if is == :absent or is.nil?
-            is.sort == self.should.sort
-        end
-
-        # svcprop returns multivalue entries delimited with a space
-        def delimiter
-            " "
-        end
-
-        validate do |value|
-            netmask, network = value
-            # check the netmask
-            begin
-                ip = IPAddr.new(netmask)
-            rescue ArgumentError
-                # the value wasn't a valid IP address, so check the hostname
-                raise Puppet::Error, "securenets entry:  #{value} has an
-                    invalid netmask" if not valid_hostname? netmask
-            end
-
-            begin
-                ip = IPAddr.net(network)
-            rescue ArgumentError
-                # the value wasn't a valid IP address
-                raise Puppet::Error, "securenets entry:  #{value} has an 
-                    invalid network"
-            end
-        end
+              multiple entires as separate entries in the hash."
     end
 
     newproperty(:use_broadcast) do
--- a/components/puppet/files/solaris/lib/puppet/type/nsswitch.rb	Thu Aug 08 10:33:46 2013 -0700
+++ b/components/puppet/files/solaris/lib/puppet/type/nsswitch.rb	Mon Aug 12 11:30:04 2013 -0700
@@ -84,8 +84,8 @@
         desc "The alias database lookup override"
     end
 
-    newproperty(:servicde) do
-        desc "The servicde database lookup override"
+    newproperty(:service) do
+        desc "The service database lookup override"
     end
 
     newproperty(:project) do