It's possible to use JetPatch when you are working with local repositories. Here is the full guide on how to setup your environment and make sure 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.
Preconditions:
- Make sure your local repository server is registered to RHEL
- Local repository storage requirements are based on the number of endpoints connecting to the repo (specifically the /var/www mount point)
- Each operating system should have its own repository server. (i.e Repo for each of the following - RHEL 7, RHEL 6, CentOS 7..)
- Local repository must have Internet connectivity
Before we start:
1. Please take under consideration the 'repo-sync' command, which might take 9-10 hours to complete.
2. If you are familiar with repositories needed in your organization, other than the suggested below, configure them the exact same way. For example, if you need a RHEL 7.7 only repo vs 7.X, see RHEL official documentation.
RHEL8 Local Repository Setup
Step 1: Setup Nginx on Repository Server
- First start by installing Nginx HTTP server from the EPEL repository using the YUM package manager as follows.
# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# dnf install epel-release
# dnf install nginx - Once you have installed Nginx web server, you can start it for the first time and enable it to start automatically at system boot.
-
# systemctl start nginx
-
- 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
Step 2: Creating a local repository
1. Install the "yum-utils" and "createrepo" packages on the registered system.
# yum install yum-utils createrepo httpd
2. Create directories for your repositories
# mkdir /var/www/html/rhel8
Create the necessary directories (yum repositories repo_name) that will store packages and any related information:
# mkdir /var/www/html/rhel8/AppStream
# mkdir /var/www/html/rhel8/baseOS
3. Enable the repositories:
# subscription-manager repos --enable=rhel-8-for-x86_64-baseos-rpms
# subscription-manager repos --enable=rhel-8-for-x86_64-appstream-rpms
4. Check that the repositories are enabled by running (they should be with status 'enabled', highlighted in green)
# yum repolist
5. Run the reposync command for each enabled repository
# reposync -p /var/www/html/rhel8/baseOS --download-metadata --repo=rhel-8-for-x86_64-baseos-rpms
# reposync -p /var/www/html/rhel8/AppStream --download-metadata --repo=rhel-8-for-x86_64-appstream-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/rhel8/baseOS/ -g comps.xml
createrepo -v /var/www/html/rhel8/AppStream/ -g comps.xml
Note: If -g comps.xml is not running, run the command without that part.
7. Configure the updateinfo.xml file :
# FOR AppStream Repo:
# rm -rf /var/www/html/rhel8/AppStream/repodata/*updateinfo*
# cp /var/cache/dnf/rhel-8-for-x86_64-appstream-rpms-9d3886b51bb367d7/repodata/*-updateinfo.xml.gz /var/www/html/rhel8/AppStream/repodata/
# gzip -d /var/www/html/rhel8/AppStream/repodata/*-updateinfo.xml.gz
# mv /var/www/html/rhel8/AppStream/repodata/*-updateinfo.xml /var/www/html/rhel8/AppStream/repodata/updateinfo.xml
# modifyrepo /var/www/html/rhel8/Appstream/repodata/updateinfo.xml /var/www/html/rhel8/AppStream/repodata/
# For BaseOS Repo:
# rm -rf /var/www/html/rhel8/BaseOS/repodata/*updateinfo*
# cp /var/cache/dnf/rhel-8-for-x86_64-baseos-rpms-51b3b78d5698246b/repodata/*-updateinfo.xml.gz /var/www/html/rhel8/baseOS/repodata/
# gzip -d /var/www/html/rhel8/BaseOS/repodata/*-updateinfo.xml.gz
# mv /var/www/html/rhel8/BaseOS/repodata/*-updateinfo.xml /var/www/html/rhel8/BaseOS/repodata/updateinfo.xml
# modifyrepo /var/www/html/rhel8/BaseOS/repodata/updateinfo.xml /var/www/html/rhel8/BaseOS/repodata/
8. 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/conf.d/repos.conf
server {9. Restart nginx service:
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; #enable listing of directory index
}
}
# service nginx restart
Step 2: 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/rhel8/baseOS --download-metadata --repo=rhel-8-for-x86_64-baseos-rpms
createrepo -v /var/www/html/rhel8/baseOS/ -g comps.xml
reposync -p /var/www/html/rhel8/AppStream --download-metadata --repo=rhel-8-for-x86_64-appstream-rpms
createrepo -v /var/www/html/rhel8/AppStream/ -g comps.xml
rm -rf /var/www/html/rhel8/AppStream/repodata/*updateinfo*
cp /var/cache/dnf/rhel-8-for-x86_64-appstream-rpms-9d3886b51bb367d7/repodata/*-updateinfo.xml.gz /var/www/html/rhel8/AppStream/repodata/
gzip -d /var/www/html/rhel8/AppStream/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel8/AppStream/repodata/*-updateinfo.xml /var/www/html/rhel8/AppStream/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel8/Appstream/repodata/updateinfo.xml /var/www/html/rhel8/AppStream/repodata/
rm -rf /var/www/html/rhel8/BaseOS/repodata/*updateinfo*
cp /var/cache/dnf/rhel-8-for-x86_64-baseos-rpms-51b3b78d5698246b/repodata/*-updateinfo.xml.gz /var/www/html/rhel8/baseOS/repodata/
gzip -d /var/www/html/rhel8/BaseOS/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel8/BaseOS/repodata/*-updateinfo.xml /var/www/html/rhel8/BaseOS/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel8/BaseOS/repodata/updateinfo.xml /var/www/html/rhel8/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
[repo_name]
name = repo_id
baseurl = http://hostname_or_ip_address_of_repository/repo_name
gpgcheck = 0
enabled = 1
priority=1
--------------------
[AppStream]
name = rhel-8-for-x86_64-appstream-rpms
baseurl = http://hostname_or_ip_address_of_repository/baseOS
gpgcheck = 0
enabled = 1
priority=1
[BaseOS]
name = rhel-8-for-x86_64-baseos-rpms
baseurl = http://hostname_or_ip_address_of_repository/AppStream
gpgcheck = 0
enabled = 1
priority=1
Client setup Validation
To validate the process works successfully, run on a client machine the following:
yum list updates
You should be able to view all updates that can be installed.
Then, try to install an update ( run: yum instal update_name)
If the update is installed successdfully, it means the process has been completed as expected.
After each repository configuration, run the following commands on a client server to verify the updateinfo is shown:
yum clean all
yum 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.