The Smallest Example
Let us begin creating a foo
repository in the web server containing a single software package, for instance, the package htop
:
Create a folder called
foo
in/var/www/html
Download
htop
with the commandyumdownloader
Note
yumdownloader
may not be available in your system. You could figure which package provides it with the command yum provides yumdownloader
.
[root@master ~]# mkdir /var/www/html/foo
[root@master ~]# cd /var/www/html/foo
[root@master foo]# yumdownloader htop
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: distro.ibiblio.org
* epel: fedora-epel.mirror.lstn.net
* extras: linux.cc.lehigh.edu
* updates: centos.mirrors.tds.net
htop-2.2.0-3.el7.x86_64.rpm | 103 kB 00:00:00
Create the repository.
[root@master foo]# createrepo .
Up to this point, the local repository is ready to be used. Be sure to execute the command createrepo
every time any package is added or removed from the repository folder. Let us now use the repository in one of the compute nodes.
In node
c01
create a.repo
file as shown below. The.repo
file can have any name of your choice, just place it in the directory/etc/yum.repos.d
.
Warning
Please check the folder /etc/yum.repos.d
on the compute nodes and delete any existent CentOS-*.repo
file.
[root@c01 ~]# cat /etc/yum.repos.d/foo.repo
[foo]
name=foo
baseurl=http://192.168.16.1/foo
enabled=1
gpgcheck=0
priority=1
Verify that the
foo
repository exists:
[root@c01 ~]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id repo name status
core-0 core-0 10,019
foo foo 1
repolist: 10,020
Check the list of packages of the
foo
repository,htop
should be listed:
[root@c01 ~]# yum update
...
[root@c01 ~]# yum repo-pkgs foo list
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
htop.x86_64 2.2.0-3.el7 @foo
Install the package:
[root@c01 ~]# yum install htop
The procedure we showed here to use local repositories in the compute nodes can be simplified if we take advantage of Cobbler’s capabilities to manage local software repositories. In the following section we will show you how to use these capabilities.