# HG changeset patch # User saurabh.vyas@oracle.com # Date 1413911619 25200 # Node ID e7a2a94a22a2312c721a4b51266d42ece4ea313a # Parent 92d170cc406fd6a88e0d2ddc2dec5015e6a52b3b 18197420 pkg publisher provider should handle set/disable combination 19278382 svccfg provider doesn't verify properties correctly 19308306 puppet verify fails on file:/ pkg publisher diff -r 92d170cc406f -r e7a2a94a22a2 components/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb --- a/components/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb Mon Oct 20 23:00:15 2014 -0700 +++ b/components/puppet/files/solaris/lib/puppet/provider/pkg_publisher/solaris.rb Tue Oct 21 10:13:39 2014 -0700 @@ -134,13 +134,6 @@ def build_flags flags = [] - if enable = @resource[:enable] and enable != nil - if enable == :true - flags << "--enable" - elsif enable == :false - flags << "--disable" - end - end if searchfirst = @resource[:searchfirst] and searchfirst != "" if searchfirst == :true @@ -236,6 +229,13 @@ # required puppet functions def create pkg("set-publisher", build_flags, build_origin, @resource[:name]) + # pkg(5) does not allow for a new publisher to be set with the disabled + # flag, so check for it after setting the publisher + if enable = @resource[:enable] and enable != nil + if enable == :false + pkg("set-publisher", "--disable", @resource[:name]) + end + end end def destroy diff -r 92d170cc406f -r e7a2a94a22a2 components/puppet/files/solaris/lib/puppet/provider/svccfg/solaris.rb --- a/components/puppet/files/solaris/lib/puppet/provider/svccfg/solaris.rb Mon Oct 20 23:00:15 2014 -0700 +++ b/components/puppet/files/solaris/lib/puppet/provider/svccfg/solaris.rb Tue Oct 21 10:13:39 2014 -0700 @@ -20,7 +20,7 @@ # # -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # Puppet::Type.type(:svccfg).provide(:svccfg) do @@ -35,20 +35,23 @@ # only test for the existance of the property and not the value return p[:exit] == 0 elsif @resource[:ensure] == :present - # if the property doesn't exist at all, the exit code will be 1 + # if the property group or property doesn't exist at all, the exit + # code will be 1 return false if p[:exit] != 0 - # strip the leading and trailing parens if resource[:property] - # contains a slash as this indicates that a value is associated - # with it. + # turn @resource[:value] into a simple string by dropping the first + # and last array elements (the parens) and removing all double + # quotes + simple = @resource[:value][1..-2].join(" ")[1..-2].gsub(/\"/, "") + + # For properties, check the value against what's in SMF. For + # property groups, svcprop already verified the PG exists by not + # failing if @resource[:property].include? "/" - return p[:out].strip == \ - @resource[:value][1..-2].join(" ")[1..-2] + return p[:out].strip == simple + else + return p[:exit] == 0 end - # resource[:property] is a property group, not a property. - # There is no value to manipulate, but the property needs to be - # created, so return true. - return p[:exit] == 0 end end @@ -57,26 +60,32 @@ cmd = Array[command(:svccfg), "select", @resource[:fmri]] svc_exist = exec_cmd(cmd) - # Create the service instance if it doesn't exist + # Raise an error if the entity does not exist if svc_exist[:exit] != 0 - service, instance = \ - @resource[:fmri].split(":").reject{|n| n == "svc"} - svccfg("-s", service, "add", instance) + raise Puppet::Error, "SMF entity #{@resource[:fmri]} does not exist" end + + args = ["-s", @resource[:fmri]] - # Add the property if @resource[:property].include? "/" - svccfg("-s", @resource[:fmri], "setprop", @resource[:property], - "=", @resource[:type] + ":", @resource[:value]) + args << "setprop" << @resource[:property] << "=" + if type = @resource[:type] and type != nil + args << @resource[:type] + ":" + end + args << @resource[:value] else - svccfg("-s", @resource[:fmri], "addpg", @resource[:property], - @resource[:type]) + args << "addpg" << @resource[:property] << @resource[:type] end + svccfg(args) svccfg("-s", @resource[:fmri], "refresh") end def destroy - svccfg("-s", @resource[:fmri], "delprop", @resource[:property]) + if @resource[:property].include? "/" + svccfg("-s", @resource[:fmri], "delprop", @resource[:property]) + else + svccfg("-s", @resource[:fmri], "delpg", @resource[:property]) + end svccfg("-s", @resource[:fmri], "refresh") end diff -r 92d170cc406f -r e7a2a94a22a2 components/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb --- a/components/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb Mon Oct 20 23:00:15 2014 -0700 +++ b/components/puppet/files/solaris/lib/puppet/type/pkg_publisher.rb Tue Oct 21 10:13:39 2014 -0700 @@ -20,7 +20,7 @@ # # -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # require 'puppet/property/list' @@ -51,6 +51,15 @@ def retrieve provider.origin end + + # for origins with a file:// URI, strip any trailing / character + munge do |value| + if value.start_with? "file" and value.end_with? "/" + value = value.chomp("/") + else + value + end + end end newproperty(:enable) do diff -r 92d170cc406f -r e7a2a94a22a2 components/puppet/files/solaris/lib/puppet/type/svccfg.rb --- a/components/puppet/files/solaris/lib/puppet/type/svccfg.rb Mon Oct 20 23:00:15 2014 -0700 +++ b/components/puppet/files/solaris/lib/puppet/type/svccfg.rb Tue Oct 21 10:13:39 2014 -0700 @@ -20,7 +20,7 @@ # # -# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. # Puppet::Type.newtype(:svccfg) do @@ -42,7 +42,8 @@ newparam(:name) do desc "The symbolic name for properties to manipulate. This name is - used for human reference only" + meaningful only within Puppet manifests and not expressed to + SMF in any way." isnamevar end @@ -51,7 +52,9 @@ end newparam(:property) do - desc "Name of property - includes Property Group and Propery" + desc "Name of property - includes Property Group and Property. If + the service, instance, or property group does not exist, they + will be created." end newparam(:type) do @@ -61,7 +64,9 @@ newparam(:value) do desc "Value of the property" munge do |value| - # cast the value to an array + # cast the value to an array. This is done for the case where a + # property needs to be set. exists? will undo all of this and + # revert the value into a simple string for comparisons. if not value.is_a? Array value = Array[value] end