In certain cases, the cluster is not able to access the internet directly or having a local repository within the companies intranet is beneficial e.g. in the case were a site is hosting multiple clusters. This KB article will describe how to create a local repository using the head node’s web server when running Ubuntu. The same steps will work for Ubuntu servers in general if you want to host a repository on a third party server.
Make packages available
The first step is to create a directory under /var/www/html/ that contains the packages you want to make available. This will use the existing head node web server to provide the files. For example, create /var/www/html/repos:
# mkdir /var/www/html/repos
We now need to put packages into this directory. Two common ways to obtain packages are to copy the installer ISO packages or mirror a remote repository.
Copy ISO packages
To copy the installer ISO packages mount a copy of the installer ISO locally and copy the packages to the newly created directory.
# mkdir /mnt/iso # mount bcm-10.0-ubuntu2204.iso /mnt/iso # cp -r /mnt/iso/data/packages/ /var/www/html/repos/
Note: This will copy all of the ISO packages to your local head node repository. You can specify a direct path to only copy certain architectures or packages as desired instead of the broader /mnt/iso/data/packages, e.g. /mnt/iso/data/packages/dist/ubuntu/2204/.
Mirroring remote repository
To mirror a remote repository a suggested but not officially endorsed tool to use is apt-mirror. You can install apt-mirror via the apt package manager.
# apt update; apt install apt-mirror -y
After installation modify the /etc/apt/mirror.list file and configure as desired. A minimum suggested configuration is to uncomment the “set base_path” configuration option and specify a path where you want the mirrored repository to be downloaded. Review the list of repository entries to include those you want to mirror.
Once you are satisfied with the configuration you can run apt-mirror to begin mirroring the remote repositories. You may want to run this in a screen or tmux session as there may be a lengthy download of packages.
# apt-mirror
Create Packages.gz file
Depending on how you copied your packages and the source, your repository will also need a Packages.gz file. This command will change to the newly created directory, scan all of the packages contained in it, and create a compressed Packages file.
# cd /var/www/html/repos; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
Note: Some paths in the ISO have an existing Packages.gz that can be used as shown in the section below on adding the repo to clients.
At this point the newly created repository is functional.
Add repo to clients
You can now add the repository to /etc/apt/sources.list on systems where you want to use the new repository.
Add the following to the sources.list file, note that the IP 10.141.255.254 should change to the DNS name or IP of the server that will be reachable by the server you are adding the repository to. You will need to run apt update afterwards.
# echo "deb [trusted=yes] http://10.141.255.254/repos/ ./" >> /etc/apt/sources.list # apt update
To use your new repository in software images use the cm-chroot-sw-img command to modify the /etc/apt/sources.list file.
# cm-chroot-sw-img /cm/images/<image name>
Modify /etc/apt/sources.list to include the new repository. Again note that the 10.141.255.254 IP should change to the DNS name or IP of the repository server. You will need to run apt update after adding the new repository.
# echo "deb [trusted=yes] http://10.141.255.254/repos/ ./" >> /etc/apt/sources.list # apt update
Note: The source format expects a Packages.gz file to exist at the path specified. Some paths from the ISO already include a Packages.gz that can be used if desired, for example:
deb [trusted=yes] http://10.141.255.254/repos/packages/dist/ubuntu/2204/ ./ deb [trusted=yes] http://10.141.255.254/repos/packages/10.24.07/ubuntu/2204/ ./ deb [trusted=yes] http://10.141.255.254/repos/packages/packagegroups/hpc ./
You should now be able to use your new repository to install packages.