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.
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.
yum install epel-release
yum 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/rhel7
Create the necessary directories (yum repositories repo_name) that will store packages and any related information:
mkdir /var/www/html/rhel7/server
mkdir /var/www/html/rhel7/rhscl
mkdir /var/www/html/rhel7/main
3. Enable all relevant repositories:
subscription-manager repos --enable=rhel-7-server-rpms
subscription-manager repos --enable=rhel-7-server-optional-rpms
subscription-manager repos --enable=rhel-server-rhscl-7-rpms
4. Once all of these repos have been enabled, perform the following command for all of them changing the download_path for each to match the download_path for that repository.
reposync --gpgcheck -l --repoid=rhel-7-server-optional-rpms --download_path=/var/www/html/rhel7/server --downloadcomps --download-metadata
reposync --gpgcheck -l --repoid=rhel-server-rhscl-7-rpms --download_path=/var/www/html/rhel7/rhscl --downloadcomps --download-metadata
reposync --gpgcheck -l --repoid=rhel-7-server-rpms --download_path=/var/www/html/rhel7/main --downloadcomps --download-metadata
5. Run the create repository command (for each repository that was enabled and synced in previous steps).
touch /var/www/html/rhel7/server/comps.xml
createrepo -v /var/www/html/rhel7/server/ -g comps.xml
createrepo -v /var/www/html/rhel7/rhscl/
createrepo -v /var/www/html/rhel7/main/
Note: The -g comps.xml is only needed for the server repo.
6. Configure the updateinfo.xml file by running the following commands :
-------------------------------
REPOSITORY CONFIG FOR rhel-7-server-optional-rpms to "server" FOLDER:
==================
rm -rf /var/www/html/rhel7/server/repodata/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-7-server-optional-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/server/repodata/
gzip -d /var/www/html/rhel7/server/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/server/repodata/*-updateinfo.xml /var/www/html/rhel7/server/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/server/repodata/updateinfo.xml /var/www/html/rhel7/server/repodata/
-------------------------------
REPOSITORY CONFIG FOR rhel-7-server-rpms to "Main" FOLDER:
==================
rm -rf /var/www/html/rhel7/main/repodata/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-7-server-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/main/repodata/
gzip -d /var/www/html/rhel7/main/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/main/repodata/*-updateinfo.xml /var/www/html/rhel7/main/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/main/repodata/updateinfo.xml /var/www/html/rhel7/main/repodata/
-------------------------------
REPOSITORY CONFIG FOR rhel-server-rhscl-7-rpms to "rhscl" FOLDER:
==================
rm -rf /var/www/html/rhel7/rhscl/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-server-rhscl-7-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/rhscl/repodata/
gzip -d /var/www/html/rhel7/rhscl/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/rhscl/repodata/*-updateinfo.xml /var/www/html/rhel7/rhscl/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/rhscl/repodata/updateinfo.xml /var/www/html/rhel7/rhscl/repodata/
7. 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.confAdd the following configuration to file repos.conf.
server {8. 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
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 --gpgcheck -l --repoid=rhel-7-server-rpms --download_path=/var/www/html/rhel7/main --downloadcomps --download-metadata
createrepo --update /var/www/html/rhel7/main/
reposync --gpgcheck -l --repoid=rhel-7-server-optional-rpms --download_path=/var/www/html/rhel7/server --downloadcomps --download-metadata
createrepo --update /var/www/html/rhel7/server/ \\
reposync --gpgcheck -l --repoid=rhel-server-rhscl-7-rpms --download_path=/var/www/html/rhel7/rhscl --downloadcomps --download-metadata
createrepo --update /var/www/html/rhel7/rhscl/
rm -rf /var/www/html/rhel7/server/repodata/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-7-server-optional-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/server/repodata/
gzip -d /var/www/html/rhel7/server/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/server/repodata/*-updateinfo.xml /var/www/html/rhel7/server/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/server/repodata/updateinfo.xml /var/www/html/rhel7/server/repodata/
rm -rf /var/www/html/rhel7/main/repodata/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-7-server-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/main/repodata/
gzip -d /var/www/html/rhel7/main/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/main/repodata/*-updateinfo.xml /var/www/html/rhel7/main/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/main/repodata/updateinfo.xml /var/www/html/rhel7/main/repodata/
rm -rf /var/www/html/rhel7/rhsc/repodata/*updateinfo*
cp /var/cache/yum/x86_64/7Server/rhel-server-rhscl-7-rpms/*-updateinfo.xml.gz /var/www/html/rhel7/rhscl/repodata/
gzip -d /var/www/html/rhel7/rhscl/repodata/*-updateinfo.xml.gz
mv /var/www/html/rhel7/rhscl/repodata/*-updateinfo.xml /var/www/html/rhel7/rhscl/repodata/updateinfo.xml
modifyrepo /var/www/html/rhel7/rhscl/repodata/updateinfo.xml /var/www/html/rhel7/rhscl/repodata/
echo Update script ended at $(date) >> /var/log/update-repository.log
chmod 600 /usr/local/bin/update-repository.sh
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
--------------------
[mainrepo]
name = jetpatch-7-server-rpms
baseurl = http://hostname_or_ip_address_of_repository/main
gpgcheck = 0
enabled = 1
priority=1
[server]
name = jetpatch-7-server-optional-rpms
baseurl = http://hostname_or_ip_address_of_repository/server
gpgcheck = 0
enabled = 1
priority=1
[rhscl]
name = jetpatch-server-rhscl-7-rpms
baseurl = http://hostname_or_ip_address_of_repository/rhscl
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.
We're all Set!
Error Handling
1. If you're encountering the following error when installaing nginx: yum error “Cannot retrieve metalink for repository: epel. Please verify its path and try again” updating ContextBroker
Solution:
Edit both /etc/yum.repos.d/epel.repo and /etc/yum.repos.d/epel-testing.repo files commenting all entries starting with mirrorlist=... and uncommenting all the entries starting with baseurl=.... ;
run again yum install nginx
2. If files do not appear when viewing the repositories from web browser:
Solution: restorecon -R /var/www/html/repos
3. If you have any issues such as Error 404 page not found it might be related to your nginx configuration. To view nginx errors go to /var/log/nginx/error.log . Errors might be related to nginx configuration (etc/nginx/conf.d/repos.conf). Please make sure you configured it properly.
4. In case you have changed configurations (in repo server) do not forget to run 'yum clean all' and 'yum repolist all' afterwards. If you have changed nginx conf. restart nginx service.
Comments
0 comments
Please sign in to leave a comment.