Hi.
I've been trying to develop a module for managing Cobbler from puppet.
So, I need a custom type - cobblerdistro, which will fetch ISO from
http, unpack it at desired destination and register distro with Cobbler.
I have one issue with ensure => absent situation.
First of all, here is my type:
<code>
# cat type/cobblerdistro.rb
Puppet::Type.newtype(:cobblerdistro) do
@doc = "Manages the Cobbler distros.
A typical rule will look like this:
distro {'CentOS-6.3-x86_64':
ensure => present,
arch => 'x86_64',
isolink =>
'http://mi.mirror.garr.it/mirrors/CentOS/6.3/isos/x86_64/CentOS-6.3-x86_64-bin-DVD1.iso',
}
This rule would ensure that the kernel swappiness setting be set to '20'"
desc "The cobbler distro type"
ensurable
newparam(:name) do
isnamevar
desc "The name of the distro, that will create subdir in $distro"
end
newparam(:arch) do
desc "The architecture of distro (x86_64 or i386)."
newvalues(:x86_64, :i386)
munge do |value| # fix values
case value
when :amd64
:x86_64
when :i86pc
:i386
else
super
end
end
end
newparam(:isolink) do
desc "The link of the distro ISO image."
validate do |value|
unless value =~ /^http:.*iso/
raise ArgumentError, "%s is not a valid link to ISO image." % value
end
end
end
newparam(:destdir) do
desc "The link of the distro ISO image."
validate do |value|
unless Pathname.new(value).absolute?
raise ArgumentError, "Full pathname must be set"
end
end
end
end
</code>
Now, how can I ensure that destdir param is obligatory? I don't want my
provider to run at all, if destdir is not specified in the resource.
So, for example, I want to spew error if user writes this code:
cobblerdistro {'CentOS-6.3-x86_64':
ensure => absent,
}
and want this to be a minimal code snippet
cobblerdistro {'CentOS-6.3-x86_64':
ensure => absent,
destdir => '/distro',
}
Otherwise, I have to hardcode the destination directory for distribution
releases and I don't want to do that :(
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" 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-users?hl=en.