Created
March 3, 2015 18:13
-
-
Save mcallaway/4fe969aace75c11735ea to your computer and use it in GitHub Desktop.
type definition for packagelock (trial)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Puppet::Type.newtype(:packagelock) do | |
| desc <<-EOT | |
| Lock a package to the specific version installed. This resource | |
| type supplements the package resource type, to lock a package | |
| to the version that is installed with the corresponding package | |
| resource. | |
| # DO NOT autorequire, we want the ability to lock *before* the package. | |
| # | |
| # **Autorequires:** If Puppet is managing the package with the same | |
| # name as the packagelock name, the packagelock resource will | |
| # autorequire the package. | |
| # | |
| EOT | |
| # We want to lock a particular version of a package. | |
| feature :versionable, "The provider is capable of interrogating the | |
| packagelock list for installed version(s), and can select | |
| which out of a set of available versions of a packagelock to | |
| install if asked." | |
| ensurable do | |
| desc "What state the packagelock should be in." | |
| newvalue(:present, :event => :package_installed) do | |
| provider.create | |
| end | |
| aliasvalue(:installed, :present) | |
| newvalue(:absent) do | |
| provider.destroy | |
| end | |
| newvalue(/./, :required_features => :versionable) do | |
| begin | |
| provider.create | |
| rescue => detail | |
| self.fail Puppet::Error, "Could not update: #{detail}", detail | |
| end | |
| if self.retrieve == :absent | |
| :package_installed | |
| else | |
| :package_changed | |
| end | |
| def insync?(is) | |
| p 'insync?' | |
| is.sort == should.sort | |
| end | |
| end | |
| defaultto :present | |
| end | |
| newparam(:name, :namevar => true) do | |
| desc "The name of the software package to lock." | |
| end | |
| # Don't autorequire, manage packages and locks separately so that we | |
| # can use locks to limit yum's ability to see available packages. | |
| # autorequire(:package) do | |
| # self[:name] | |
| # end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment