Hi.

I'm trying to create a bunch of types to manage an installation server
via cobbler. However, I don't really understand how to do it.

For example a cobbler repository is actually a record describing a YUM
repository. This could be a local mirror. So there are some
variables/properties describing such a repository:

name, source-URL, architecture, wether to mirror locally

Let's assume I have a few scripts I could use to do various tasks (i.e.
I will use shell scripts for now, to make the cobbler type (and, if
needed, provider(s)) simpler and more easy to understand, but would
implement the logic in ruby later. I have:

repo_update_or_add name url arch local
(updates the repo named or create it if it doesn't yet exist)
repo_exists name
(returns 0 if a repository with the given name exists, 1 otherwise)
repo_up_to_date name url arch local
(returns 0 if the repository exists and is up to date)
repo_delete name
(removes a repository)

Where up to date just means the parameters (i.e. is set to have a local
mirror when this is requested), not necessarily that the local mirror is
in sync with the original source.

Now, how would I write type (and if needed: provider(s)) if my
requirements are that ensure can take:
- present (just make sure the repository is known, not necessarily in
  sync with (all) parameters)
- absent (remove repositories which were once installed
- insync (known and in sync with all given parameters)

I did write a preliminary type, but it doesn't seem to work at all (see
below). I put the attached file in
/etc/puppet/modules/puppet/type/cobbler_repo.rb as per
http://reductivelabs.com/trac/puppet/wiki/PluginsInModules, with
effective puppetmasterd configuration containing:
modulepath = /etc/puppet/modules:/usr/share/puppet/modules

But still I get:

err: Could not retrieve catalog: Could not find resource type
cobbler_repo at /etc/puppet/manifests/classes/cobbler.pp:171 on node
op-inst01.wirecard.sys

Could anyone please help me?


regards,
Sven

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

module Puppet
        newtype(:cobbler_repo) do
                ensurable
                @doc = "Ensure a specific cobbler repository exists or doesn't 
exist."

                newparam(:name) do
                        desc "The name of the repository as seen by cobbler"
                end

                newparam(:source) do
                        desc "The source URL for the repository"
                end

                newparam(:local) do
                        desc "Wether to use a local copy of the repository (1) 
or a remote one (0)"

                        defaultto 1

                        validate do |value|
                                unless value =~ /^[01]$/
                                        raise Puppet::Error, "Invalid value for 
parameter local (valid: 1|0)"
                                end
                        end
                end

                newproperty(:ensure) do
                        desc "Wether the repository state should be \"present\" 
or \"absent\""

                        defaultto :present

                        def retrieve
                                ret=`cobbler repo list | grep -qE 
'(^|[[:space:]])#{name}([[:space:]]|$)'; echo $?`
                                ret ? :absent : :present
                        end
                        newvalue :absent do
                                ret=`cobbler repo remove --name="$name"`
                        end
                        newvalue :present do
                                ret=`cobbler repo add --name="#{name}" 
--mirror="#{source}" --mirror-locally=#{local}`
                        end
                end
        end
end

Reply via email to