Hello all. I'm trying to implement my own ensurable method to extend the
ensure parameter with my own possible values. I've used
puppet/type/file/ensure.rb as my example on how to do this. However, puppet
doesn't seem to be using my plugin's ensurable method since it throws this
error:
err: Could not run Puppet configuration client: Parameter ensure failed:
Invalid value "latest". Valid values are present, absent.
Here's my code:
====svn_deploy/lib/puppet/type/svn_deploy/ensure.rb====
module Puppet
Puppet::Type.type(:svn_deploy).ensurable do
require 'etc'
desc "Whether to check out or update subversion repositories on the
local system.
Possible values are *present*, *absent*, *installed*, and *latest*."
newvalue(:absent) do
if @resource.provider.exists?
@resource.provider.destroy
end
end
newvalue(:present) do
unless @resource.provider.exists?
@resource.provider.create
end
end
aliasvalue(:installed, :present)
newvalue(:latest) do
unless @resource.provider.latest?
@resource.provider.update
end
end
end
end
====svn_deploy/lib/puppet/type/svn_deploy.rb====
Puppet::Type.newtype(:svn_deploy) do
@doc = "Deploy a subversion project."
ensurable
#If we have a subversion package resource, require it
autorequire(:package) do
"subverson"
end
newproperty(:source) do
desc "The URL for the source to check out."
validate do |value|
unless value =~ /^(http[s]*|svn):\/\//
raise ArgumentError, "%s is not a valid URL" % value
end
end
end
newparam(:destination) do
desc "The file path location to check the source out to."
validate do |value|
unless value =~ /^(http[s]*|svn):\/\//
raise ArgumentError, "%s is not a valid URL" % value
end
end
end
newparam(:destination) do
desc "The file path location to check the source out to."
validate do |value|
unless value =~ /^\/[a-z0-9]+/
raise ArgumentError, "%s is not a valid file path" % value
end
end
end
newparam(:name) do
desc "The name of the subversion project."
end
newparam(:user) do
defaultto ''
desc "The username to use to authenticate to the repository."
end
newparam(:password) do
defaultto ''
desc "The password for the username specified by the user parameter."
end
newparam(:autorevert) do
defaultto false
desc "Revert local modifications if they exist."
validate do |value|
if value == true and @resource[:ensure] != 'latest'
warnonce "Cannot autorevert unless ensure is 'latest'"
end
end
end
newparam(:destroy_local_mods) do
defaultto false
desc "Destroy the check out if there are local mods present. Unlike
autorevert, this allows the entire check out to be deleted or replaced."
end
end
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
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.