Saturday, February 26, 2022

[SOLVED] Configuring yum repo to install packages only from my company internal network

Issue

I am trying to configure my yum repo on my centos7 machine to install packages only from my internal repository. To do that, I have done following changes:

  1. Moved all the current repo configurations to different location:

    sudo mv /etc/yum.repos.d/*.repo ~/backup_yum_repos/

  2. Create a new file Mycompany-internals.repo under /etc/yum.repos.d

  3. Added following contents to it:

[Mycompany-internals]
name=Mycompany-internals
baseurl=http://linux-repo.my-company.com/abc-2021q2-sr/CentOS-$releasever-$basearch/RPMS.all/
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel-debuginfo/
baseurl=http://linux-repo.my-company.com/epel/abc-2021q2-sr/epel/epel-source/
baseurl=https://linux-repo.my-company.com/utilities/avamar/CentOS$releasever/
baseurl=https://linux-repo.my-company.com/utilities/splunk/v8/
baseurl=http://linux-repo.my-company.com/utilities/perforce/perforce
baseurl=http://linux-repo.my-company.com/utilities/docker/docker/
enabled=1
gpgcheck=0


Now, I expect a normal yum installation to work using my registry mentioned above.

But when I run yum install docker (for example), it fails with error:

Loaded plugins: changelog, fastestmirror, langpacks, priorities
Loading mirror speeds from cached hostfile
My-company-internal                                                                                                              | 2.5 kB  00:00:00     
My-Company-internal/primary_db                                                                                                   |  42 kB  00:00:00     
No package docker available.
Error: Nothing to do

Solution

You are using baseurl= statement multiple times which is bad, below is a quote from yum.conf man page:

              baseurl Must be a URL to the directory where the yum repository's `repodata' directory lives. Can be an http://, ftp://  or
              file:// URL. You can specify multiple URLs in one baseurl statement. The best way to do this is like this:
              [repositoryid]
              name=Some name for this repository
              baseurl=url://server1/path/to/repository/
                      url://server2/path/to/repository/
                      url://server3/path/to/repository/

              If  you  list  more than one baseurl= statement in a repository you will find yum will ignore the earlier ones and probably
              act bizarrely. Don't do this, you've been warned.


Answered By - scroveez
Answer Checked By - Robin (WPSolving Admin)