Here is a tool that lets Solaris sysadmins ensure that a particular SMF / svc property is set in a particular fashion. In particular, I'm going to be using it to make sure that /network/smtp:sendmail config/local_only = true I've tried to code it so that it can handle all sorts of properties though.
I looked at the "forge" thing, and the "puppet-module" tool. Sad to say, I did not like it, for this purpose. It seems too complex compared to the alternatives. For the record, I deploy puppet by downloading the tarfiles, and running ruby install.rb So.. I'm going to publicly release my sysprop type here for now. Future versions may probably be found on my website, http://www.bolthole.com, but I cant give a specific url for now, because I'm not sure whether I'm going to make a puppet/ subsection or not Depends on whether or not I write more providers. Since I'm not sure how google groups, or the actual mailing list, handles attachments, I'm going old school and using shar for this :) If you have "unshar", just run it on this post. If you dont, then hand-trim out the top part and feed it directly to 'sh'. If you like, (and you're very trusting :) you should be able to extract directly in the "puppet" dir, and the two files will go to where they belong. # This is a shell archive. Save it in a file, remove anything before # this line, and then unpack it by entering "sh file". Note, it may # create directories; files and directories will be owned by you and # have default permissions. # # This archive contains: # # provider/sysprop/solaris.rb # type/sysprop.rb # echo x - provider/sysprop/solaris.rb mkdir -p provider/sysprop 2>/dev/null sed 's/^X//' >provider/sysprop/solaris.rb << 'END-of-provider/sysprop/solaris.rb' XPuppet::Type.type(:sysprop).provide(:solaris) do X desc "Solaris provider for svcprop type" X defaultfor :operatingsystem => :solaris X X commands :svccfg => "/usr/sbin/svccfg" X commands :svcprop => "/usr/bin/svcprop" X commands :svcadm => "/usr/sbin/svcadm" X X def create X svccfg("-s",resource[:fmri],"setprop",resource[:property],"=",resource[:value]) X refresh="/usr/sbin/svcadm refresh #{@resource[:fmri]}" X execute(refresh) X end X def destroy X raise ArgumentError, "sysprop cant really destroy a property. Define a value for it instead" X end X X def exists? X if ("#{@resource[:property]}" == "") X raise ArgumentError, "sysprop requires 'property' to be defined" X end X if ("#{@resource[:value]}" == "") X raise ArgumentError, "sysprop requires 'value' to be defined" X end X X output = svcprop("-p", @resource[:property], @resource[:fmri]).strip X #Puppet.debug "svcprop return value is '#{output}'" X X if output == "#{@resource[:value]}" X return true X end X X return false X end X Xend X X END-of-provider/sysprop/solaris.rb echo x - type/sysprop.rb mkdir type 2>/dev/null sed 's/^X//' >type/sysprop.rb << 'END-of-type/sysprop.rb' Xmodule Puppet X newtype(:sysprop) do X @doc = "Handle `system properties`. Inspired by solaris svcprop, and X primarily implemented for that purpose, although could theoretically have X providers for other systems as well X X X Sample usage: X sysprop { X "solaris-localvar": X ensure=>present, X fmri=>"network/smtp:sendmail", X property=>"config/local_only", X value=>true, X } X X Note: X - You must have "ensure=>present" for it to work. X" X X ensurable do X defaultvalues X def change_to_s(oldstate,newstate) X if ( oldstate == :absent && newstate == :present ) X return "set #{@resource[:property]} = #{@resource[:value]}" X end X end X end X X newparam(:name) do X desc "Label for this resource" X isnamevar X end X newparam(:fmri) do X # Do NOT make this 'namevar'. This way, it allows the X # setting of multiple properties for a single fmri X desc "FMRI that the property is associated with" X end X newparam(:property) do X desc "Specific name of the property to be set or checked for the FMRI" X end X newparam(:value) do X desc "Value to set/check for the named property" X end X X end Xend END-of-type/sysprop.rb exit -- You received this message because you are subscribed to the Google Groups "Puppet Developers" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-dev/-/kYhDSDzGfHcJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
