On Mon, Jan 24, 2011 at 5:40 PM, Erik <palehose@gmail.com>
wrote:> I''m just starting out with Puppet (version 2.6.4 installed),
trying to
> figure out how to migrate an old Cfengine 2 implementation. The
> packages we build and install internally are made using pkgsrc, for
> which we have no repository. The way we presently install packages in
> cfengine 2 is as follows:
>
> 1) Define a target called "has_packagename" if the package is
> installed (found by returncode of "pkg_info packagename").
> 2) In shellcommands section, include a literal shell command "pkg_add
> ftp://internal-file-server/path/to/package", which will be executed if
> has_packagename is not defined.
>
> This is obviously quite ugly, and I would like to find a better way of
> doing it with Puppet. I''d also like to move the packages out of
the
> anonymous internal FTP server and use Puppet''s fileserver to serve
the
> files instead (though this is not 100% necessary). I have spent
> several hours looking for a way to install these packages using
> Puppet, and it seems like I will need to write my own provider to
> accomplish this, but I don''t even know where to begin.
I''m not
> familiar with Ruby, and that seems to be the language that would be
> used to create a provider. Can anyone help point me in the right
> direction?
If they are repackaged using your OS preferred package system, you can
manage them as a package resource.
If you want to maintain the existing CFengine behavior, you can model
it with an exec resource (examples omitting attributes such as
user/path for brevity).
exec {
"pkg_add ftp://internal-file-server/path/to/package":
unless =>"pkg_info packagename"
}
If you wish to serve the file from some other means you can use the
require dependency. I recommend VCSrepo for large files, or mount
them.
Putting it together as well as making it a custom resource type (which
does not require ruby), simply write:
define my_pkg {
file {
"/local/path/to/${name}":
source => "puppet:///modules/mod_name/${name},
}
exec {
"pkg_add /local/path/to/${name}":
unless =>"pkg_info ${name}",
require => File["/local/path/to/${name}"],
}
}
To install a package foo, simply use your new custom resource:
my_pkg { "foo": }
Thanks,
Nan
--
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
puppet-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.