This article contains the following topics:
It's possible to use JetPatch when you are working with local repositories. Here is the full guide on setting up your environment and ensuring all repositories are configured correctly and available for JetPatch usage.
Please note that the instructions below are for setting up local repositories and are not related to JetPatch functionality.
If you are familiar with repositories needed in your organization, other than the suggested below, configure them the exact same way.
Prerequisites:
- Make sure your local repository server is registered to RHEL
- Local repository storage requirements are based on the OS type, Please refer this for Storage (specifically the /var/www mount point)
- Local repository must have Internet connectivity and Need to Whitelist the Public repository URL’s of Redhat.
- Please take under consideration the 'repo-sync' command, which might take 9-10 hours to complete.
RHEL9 Local Repository Setup
Install and configure Nginx on Repo Server
1. First Create the repository file and then add the below details in the .repo file.
# vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/rhel/9/$basearch/
gpgcheck=0
enabled=1
2. Then start by installing Nginx HTTP server from the repository using the DNF package manager as follows. # dnf install # dnf install nginx
3. Once you have installed the Nginx web server, you can start and enable it.
# systemctl enable nginx
# systemctl start nginx
4. Next, you need to open port 80 and 443 to allow web traffic to Nginx service, update the system firewall rules to permit inbound packets on HTTP and HTTPS using the commands below.
# firewall-cmd --zone=public --permanent --add-service=http
# firewall-cmd --zone=public --permanent --add-service=https
# firewall-cmd --reload
5. To enable viewing of repositories and packages in them, via a web browser, create a Nginx server block which points to the root of your repositories as shown.
vim /etc/nginx/nginx.conf
Add the following configuration to file repos.conf.
server {
listen 80;
server_name repos.test.lab; #change test.lab to your real domain or IP address
root /var/www/html;
location /{
index index.php index.html index.htm;
autoindex on;
}
9. Restart nginx service and check in browser by enter http://HOST-IP/
# service nginx restart
Creating a local repository
1. Install the "dnf-utils" and "createrepo" packages on the registered system.
# dnf install dnf-utils createrepo httpd
2. Create directories for your repositories
# mkdir /var/www/html/rhel9
Create the necessary directories (yum repositories repo_name) that will store packages and any related information:
# mkdir /var/www/html/rhel9/AppStream
# mkdir /var/www/html/rhel9/baseOS
3. Enable the repositories:
# dnf config-manager --set-enabled repository-name
4. Check that the repositories are enabled by running (they should be with status 'enabled', highlighted in green)
# dnf repolist all
5. Run the reposync command for each enabled repository
# reposync -p /var/www/html/rhel9/baseOS --download-metadata --repo=rhel-9-for-x86_64-baseos-rhui-rpms
# reposync -p /var/www/html/rhel9/AppStream --download-metadata --repo=rhel-9-for-x86_64-appstream-rhui-rpms
6. Run Create repo command:
Once the packages have been downloaded all that is needed is the createrepo command below for each repo:
createrepo -v /var/www/html/rhel9/baseOS/ -g repomd.xml
createrepo -v /var/www/html/rhel9/AppStream/ -g repomd.xml
Note: If -g repomd.xml is not running, run the command without that part.
7. Configure the updateinfo.xml file located in /var/www/html/rhel9/baseos and appstream:
# FOR AppStream Repo:
# rm -rf /var/www/html/rhel9/AppStream/repodata/*updateinfo*
# cp /var/cache/dnf/rhel-9-appstream-rhui-rpms-6ecf9aed3063875f/repodata/*-updateinfo.xml.gz /var/www/html/rhel9/AppStream/repodata/
# gzip -d /var/www/html/rhel9/AppStream/repodata/*-updateinfo.xml.gz
# mv /var/www/html/rhel9/AppStream/repodata/*-updateinfo.xml /var/www/html/rhel9/AppStream/repodata/updateinfo.xml
# modifyrepo /var/www/html/rhel9/Appstream/repodata/updateinfo.xml /var/www/html/rhel9/AppStream/repodata/
# For BaseOS Repo:
# rm -rf /var/www/html/rhel9/BaseOS/repodata/*updateinfo*
# cp /var/cache/dnf/rhel-9-baseos-rhui-rpms-275092f04093a31c/repodata/*-updateinfo.xml.gz /var/www/html/rhel9/baseOS/repodata/
# gzip -d /var/www/html/rhel9/BaseOS/repodata/*-updateinfo.xml.gz
# mv /var/www/html/rhel9/BaseOS/repodata/*-updateinfo.xml /var/www/html/rhel9/BaseOS/repodata/updateinfo.xml
# modifyrepo /var/www/html/rhel9/BaseOS/repodata/updateinfo.xml /var/www/html/rhel9/BaseOS/repodata/
Create Script and Cron Job to Update Your Repositories (on repository server only)
1. Create a script named update-repository.sh and put it in /usr/local/bin with the following contents (/usr/local/bin/update-repository.sh):
echo Update script started at $(date) >> /var/log/update-repository.log
reposync -p /var/www/html/rhel9/baseOS --download-metadata --repo=rhel-9-for-x86_64-baseos-rhui-rpms
createrepo -v /var/www/html/rhel9/baseOS/ -g repomd.xml
reposync -p /var/www/html/rhel9/AppStream --download-metadata --repo=rhel-9-for-x86_64-appstream-rhui-rpms
createrepo -v /var/www/html/rhel9/AppStream/ -g repomd.xml
rm -rf /var/www/html/rhel9/AppStream/repodata/*updateinfo*
cp /var/cache/dnf/rhel-9-appstream-rhui-rpms-6ecf9aed3063875f/repodata/*-updateinfo.xml.gz /var/www/html/rhel9/AppStream/repodata/
gzip -d /var/www/html/rhel9/AppStream/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel9/AppStream/repodata/*-updateinfo.xml /var/www/html/rhel9/AppStream/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel9/Appstream/repodata/updateinfo.xml /var/www/html/rhel9/AppStream/repodata/
rm -rf /var/www/html/rhel9/BaseOS/repodata/*updateinfo*
cp /var/cache/dnf/rhel-9-baseos-rhui-rpms-275092f04093a31cb/repodata/*-updateinfo.xml.gz /var/www/html/rhel9/baseOS/repodata/
gzip -d /var/www/html/rhel9/BaseOS/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel9/BaseOS/repodata/*-updateinfo.xml /var/www/html/rhel9/BaseOS/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel9/BaseOS/repodata/updateinfo.xml /var/www/html/rhel9/BaseOS/repodata/
echo Update script ended at $(date) >> /var/log/update-repository.log
2. Grant permissions by running the following:
chmod 600 /usr/local/bin/update-repository.sh
3. Create a file in etc/cron.d and name it update-repository with the following content (the @weekly parameter stands for the interval).
Update the crontab to run the update-repository.sh every week - Edit /etc/cron.d/update-repository with the following line
@weekly root /usr/local/bin/update-repository.sh
Setting Up Client Servers
Note: The following steps should be performed on all client servers that are configured to sync with the local repositories. We highly recommend using our run-task capabilities, to easily distribute the configurations.
1. Disable all current repositories in the Local Repository server by running disable-all-repos.sh attachement on the client server.
2. Create a .repo file that will be added to the /etc/yum.repos.d directory on every server using the repositories. That file should look similar to the following file.
vi /etc/yum.repos.d/name_of_repo_file.repo
[AppStream]
name = rhel-9-for-x86_64-appstream-rhui-rpms
baseurl = http://hostname_or_ip_address_of_repository/rhel9/AppStream
gpgcheck = 0
enabled = 1
priority=1
[BaseOS]
name = rhel-9-for-x86_64-baseos-rhui-rpms
baseurl = http://hostname_or_ip_address_of_repository/rhel9/baseOS
gpgcheck = 0
enabled = 1
priority=1
Client setup Validation
To validate the process works successfully, run on a client machine the following:
dnf list updates
You should be able to view all updates that can be installed.
Then, try to install an update ( run: dnf install update_name)
If the update is installed successfully, it means the process has been completed as expected.
After each repository configuration, run the following commands on a client server to verify the update info is shown:
dnf clean all
dnf updateinfo
Run script on all endpoint servers
We highly recommend configuring adding the repo-file using our run task capabilities. In order to do so, please follow the 'Configure Local Repository on all Client Servers' instructions.
Comments
0 comments
Please sign in to leave a comment.