Create a Redhat Repository Server
A repository server is the source for installing packages after the VM
is created and running, if you want to add additional packages to the
system, you could mount the dvd and search for them, but with a repository
server online, just run yum/dnf install...
We want the repository server to host multiple versions of Rhel, so we adapt
the description on the web to our needs.
This host will act as the DNS server for the lab environment.
The server
First we need to create a lxc container, with the specs as follows:
- CPUs: 1
- Memory: 32 MB
- swap: 32 MB
- Disk: 30 GB
- template: alpine-3.20-default...
Packages
For a Repository server apache(httpd) or nginx needs to be running on the machine to service
the repositories.
So all we install on top of the container default:
- openssh
- nginx
Start the container, install openssh and nginx
reposerver:~# apk update
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
v3.20.6-102-g9a0a20524b4 [https://dl-cdn.alpinelinux.org/alpine/v3.20/main]
v3.20.6-100-g1c20a3aaca6 [https://dl-cdn.alpinelinux.org/alpine/v3.20/community]
OK: 24180 distinct packages available
reposerver:~# apk add openssh
(1/11) Installing openssh-keygen (9.7_p1-r5)
(2/11) Installing ncurses-terminfo-base (6.4_p20240420-r2)
(3/11) Installing libncursesw (6.4_p20240420-r2)
(4/11) Installing libedit (20240517.3.1-r0)
(5/11) Installing openssh-client-common (9.7_p1-r5)
(6/11) Installing openssh-client-default (9.7_p1-r5)
(7/11) Installing openssh-sftp-server (9.7_p1-r5)
(8/11) Installing openssh-server-common (9.7_p1-r5)
(9/11) Installing openssh-server-common-openrc (9.7_p1-r5)
(10/11) Installing openssh-server (9.7_p1-r5)
(11/11) Installing openssh (9.7_p1-r5)
Executing busybox-1.36.1-r29.trigger
OK: 16 MiB in 40 packages
reposerver:~# apk add nginx
(1/3) Installing pcre (8.45-r3)
(2/3) Installing nginx (1.26.3-r0)
Executing nginx-1.26.3-r0.pre-install
Executing nginx-1.26.3-r0.post-install
(3/3) Installing nginx-openrc (1.26.3-r0)
Executing busybox-1.36.1-r29.trigger
OK: 18 MiB in 43 packages
rc-update add sshd
rc-update add nginx
prepare the repository data
We will create a default documentroot in the nginx.conf, we create the following directories:
mkdir /var/www/html/rhel8
mkdir /var/www/html/rhel9
Upload the iso files to the proxmox server in the iso image store
We use a NAS cifs/smb share mounted to all proxmox nodes.
After uploading the images we mount them to the lxc-container using the following commands:
on the proxmox host:
pct set <container_id> --mp0 NAS:iso/rhel-baseos-9.1-x86_64-dvd.iso,mp=/mnt/rhel9
pct set <container_id> --mp1 NAS:iso/rhel-8.7-x86_64-dvd.iso,mp=/mnt/rhel8
This wil mount the iso's on the mountpoint specified into the lxc container.
From there we can copy the content to the local directories we created above.
cp -r /mnt/* /var/www/html/
chown -r nginx:root /var/www/*
This will take some time.
nginx configuration:
After a default installation of nginx, the file /etc/nginx/http.d/default.conf is created.
Replace the content of this file with the following:
# This is a default site configuration which will simply return 404, preventing
# chance access to any other virtualhost.
server {
listen 80;
listen [::]:80;
server_name reposerver.homelab;
index index.html;
root /var/www/html;
location / {
allow all;
sendfile on;
sendfile_max_chunk 1m;
autoindex on;
autoindex_exact_size off;
autoindex_format html;
autoindex_localtime on;
}
}
Restart the nginx server
rc-service nginx restart
If you use the proxmox firewall: Do not forget to open the firewall for http traffic...
Using the repositories
On the subsequent redhat VM's you can now enable this machine as your local repository server for yum
Place the following content in the file: /etc/yum.repos.d/local.repo
[BaseOs]
name=BaseOs packages 8.7
metadata_expire=-1
gpg_check=1
cost=500
enabled=1
baseurl=http://reposerver/rhel8/BaseOS/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
[AppStream]
name=AppStream packages 8.7
metadata_expire=-1
gpg_check=1
cost=500
enabled=1
baseurl=http://reposerver/rhel8/AppStream/
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Obviously the above is for a rhel8 installation, adapt settings for rhel9 if needed.
Your new VM can install packges from the reposerver now.