How to create a repo file
Environment
- Red Hat Enterprise Linux 5
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- Red Hat Enterprise Linux 8
- Red Hat Enterprise Linux 9
Issue
- Need to configure a client to access a local or custom repository
Resolution
Manually create a .repo file
Repositories are configured in /etc/yum.repos.d/ by files that end in .repo. Multiple repositories can be defined in the same file.
Suggested Minimal Repo Configuration
[repo-id] baseurl=http://X.X.X.X/repo gpgcheck=0 enabled=1
Additional useful options
#Describe the repo name=A descriptive name of the repo #Define the gpgkey which can be used to verify the packages. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release #Set the metadata to expire right away so the client always checks in with the host for new repodata metadata_expire=0
- There is a wide variety of options available which can be found in the man page for yum.conf
# man yum.conf
Alternately
Using yum-config-manager
To quickly generate a basic file, use yum-config-manager and target the baseurl of the repository.
# yum-config-manager --add-repo=http://X.X.X.X/repo
Diagnostic Steps
The most common problem is with the baseurl. This can target http, https, nfs, or a local file location. Ensure that the location that this is pointing to contains the repodata directory for the repository.
Common Repo Structure
Using this repository as an example, even though the packages are in Packages/b, the baseurl of any client would need to point to the root directory repository. This is where the repodata directory sits and that tells the clients what packages are available and where they are.
repository/ ├── Packages │ └── b │ └── bash-5.1.8-6.el9_1.x86_64.rpm └── repodata ├── 0c54fd2a8dc26014b14ec6460c1e33f64a3e8d368b139ac2fb3e45b8fc2dcf85-other.sqlite.bz2 ├── 16725242e2cc2f28fa1c81a62f1bb46a9007c017f31191320258d35bc54ff130-filelists.xml.gz ├── 17a6f9ce66beaa549b87269878901bcba422653d29e3ddb1898e84d79bdbe09a-filelists.sqlite.bz2 ├── 98c8e2406f8dc46908a0e4fd5b2793739738be2e0f8f8042cc41c0908bde51ee-other.xml.gz ├── a1d40695dd3fc9e09cb8794833db548d7a7fb7f7d92330b8093334b74413b504-primary.xml.gz ├── c8544ccedbf872e8d5d5fa61353dd05266ba9a36d4bfc284ef4edd5b7367846a-primary.sqlite.bz2 └── repomd.xml
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.