|
A repository is much like a library for the operating system. |
Had a fun task at work today so wanted to write a quick post about it. A linux system receives its OS and software updates from a location called the 'Repository', for an Operating System such as CentOS or Ubuntu, the repositories come pre-listed with the operating system and there's no addition work involved.
|
Fig. 1 - Ubuntu repolist |
However, for the Red Hat operating systems which are paid, you need to manually register the system to the Red Hat customer portal and then need to attach a subscription. The command to do so looks like the following:
subscription-manager register --username <username> --password <password> --auto-attach
Doing so will give us access to the repositories from which we can install our packages and update existing ones. As you can imagine, different versions of Red Hat would have different repositories and they wouldn't be interoperable. If any of you have tried installing a class game such as 'Road Rash' on a newer Windows 10 machine without using compatibility mode, you would know exactly what I'm on about. In our production systems, we have an amalgam of RHEL 7 and RHEL 8 systems.
Some of our systems do not have access to the internet, so the way we ensure that all our VMs have access to the repositories is to connect one of the RHEL systems in the DMZ to the Red Had customer portal and then we create a local mirror from it. Here's a basic idea of
how to do that:
1. Install the required packages -> yum install yum-utils createrepo https
2. Create a directory to store repos -> mkdir -p /var/www/html/repos
3. Sync Red Hat repos -> reposync --gpgcheck -l --repoid=<based on the OS e.g. RHEL 7 or RHEL 8> --download_path=/var/www/html/repos
NOTE: A few steps are missing, for example, getting the repolist from the /etc/yum.repos.d/redhat.repo file and then writing a stream editor line to get just the repo name which would be used as an input for the repo sync command.
So, for our systems, we had one such VM setup for Red Hat 8 and another for Red Hat 7, we wished to consolidate them into one VM for the following reasons:
1. Easier to remember just one IP address for repo server,
2. Only need one web server running, which
3. Simplifies management and is easier to maintain.
The way we decided to do that was to have a RHEL 8 system on which we would install Apache webserver and then have RHEL 7 running as a docker container with a shared volume or a bind mount. We were able to get the
official RHEL 7 docker image file from red hat.
docker pull registry.access.redhat.com/rhel7:7.9-848
We used this as the base image to run our RHEL 7 container and have a bind mount with the base RHEL 8 operating system.
docker run -itd --name R7_Repo_Container --mount type=bind,source=/var/www/html/r7_repos,target=/var/www/html/repos rhel7:latest
Then we copied the scripts to the root directory of the Docker container from the base system using the following command:
docker cp /home/scripts/redhat7scripts /root <container_name or container_id>
Then, manually exec'ed into the container, added execute permissions to the script and ran the scripts.
docker exec -it <container id> /bin/bash
Now that we know all the steps involved in creating this Docker container, our improvement idea for this is to create a Dockerfile that would help us get the container up & running quickly. That's it for this post! Thanks for reading and please feel to comment any improvement suggestions you may have.
Comments
Post a Comment