Local yum repositories

19
May
2010

Thanks to lots of help from Ben Cotton and Jordan Sissel, I’ve finally managed to get some RPMs built. This is a Good Thing(tm).
The reason that it’s good is because once I have RPMs of the various software that I need to install, I can create a local (internal) yum repository. And that is a Very Good Thing(tm).
I mentioned it briefly a while back, but I’ve been working with puppet, and installing things through the puppet fileserver is miserable. However, I can specify additional repositories for my machines using puppet, AND I can specify that packages are installed. Combine those two, and you’ve got a powerful combination for getting software installed where it needs to be.
I had my first success last night, installing a custom-packaged JVM. Honestly, after figuring out the spec file, the repo is simple.
All you need to create a repo is a directory accessible by web browser. For instance, on the host that I’m using to build my RPMs, I made ~/public_html/repo. Inside that, I created i386, x64, and noarch subdirectories. At this point, you need to toss the RPMs that you’ve made into the proper directories, then run “createrepo ~/public_html/repo/noarch”, for instance, and voila! Instant repo.
On the machine that you want to have talking to that repository, go into /etc/yum.repos.d/ and create “my-internal.repo” (or whatever you want to name it), and put lines equivalent to the following

[Internal-Repository]
name=Matt's Internal yum repository of doom
baseurl=http://webserver/~msimmons/repo/noarch
gpgcheck=0

At this point, you can do “yum search” and a package name that you’ve put in your repository, and it’ll find it.

[root@mymachine ~]# yum search jdk1.6.0_12
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* addons: mirrors.netdna.com
* base: mirrors.netdna.com
* epel: serverbeach1.fedoraproject.org
* extras: mirror.ubiquityservers.com
* updates: mirror.ash.fastserv.com
============================= Matched: jdk1.6.0_12 =============================
jdk1.6.0_12_x64.noarch : jdk1.6.0_12_x64 installed into
: /usr/local/jdk1.6.0_12_x64 - Packaged by Matt Simmons
: 20100518
[root@mymachine ~]#

How awesome is that? Pretty awesome, in my opinion.
Of course, there are more uses for this than just installing customized software. You can also use it to create a local mirror of a repository. This is useful if you have a bunch of machines on which the software needs updated, but you don’t want to kill your network bandwidth by having everyone go talk to a remote repo at the same time. Instead, you mirror the remote repo to your internal repo, then replace the default yum repo with your internal repo. Problem solved!
This use case does have the added benefit of your being able to have finely grained control of which software packages make it onto your machines, as well. It’s not hard to conceive of a “testing” repo, where you run packages to make sure they don’t blow up your configs, and after having proven themselves, get moved to the “production” repo.
Also, implementing something like this can absolve you of the necessity to use extra repositories like EPEL, which may contain the software you want to install, but also contain other packages that might conflict with another configured repo package.
I can see myself really leveraging this in the future. It’s too powerful of a tool not to use. I wish I would have learned about it sooner, but I didn’t, so I’m sharing it in the hopes that someone else is inspired to check it out and start implementing it too.
Do you use an internal repo? Why or why not? Also, if you do have a repo, what tips can you give us on how to best use it? Comment below!



See original: JorgeE's shared items in Google Reader Local yum repositories