Posted on
Administration

Setting up a centralized update server for RHEL

Author
  • User
    Linux Bash
    Posts by this author
    Posts by this author

Streamlining Updates: Setting Up a Centralized Server for RHEL Using Linux Bash

For organizations relying on Red Hat Enterprise Linux (RHEL) across multiple systems, managing updates can be a cumbersome and time-consuming process. Centralizing this process not only helps in saving bandwidth and time but also ensures consistency in the updates applied across all systems. In this blog, we'll explore how to set up a centralized update server for RHEL and provide instructions for integrating it with various package managers such as DNF (the default for RHEL), APT (commonly used in Debian-based systems), and Zypper (used in openSUSE).

Step 1: Setting Up the Update Server

The first step in creating a centralized update server is setting up a local repository server that will store all the updates. For RHEL systems, this can typically be done using the reposync utility, which synchronizes a remote repository to a local directory.

Requirements:

  • A RHEL server (this will act as the update server)

  • Sufficient storage space for the repository data

  • Network access to a public RHEL repository

Instructions:

  1. Install the required tools:

    sudo dnf install -y createrepo yum-utils
    
  2. Create a directory to store the repositories:

    sudo mkdir -p /var/www/html/repos
    
  3. Sync RHEL repositories:

    sudo reposync -g -l -d -m --repoid=rhel-8-for-x86_64-baseos-rpms --newest-only --download-metadata --download_path=/var/www/html/repos/
    sudo reposync -g -l -d -m --repoid=rhel-8-for-x86_64-appstream-rpms --newest-only --download-metadata --download_path=/var/www/html/repos/
    
  4. Initialize the local repository:

    sudo createrepo /var/www/html/repos/rhel-8-for-x86_64-baseos-rpms
    sudo createrepo /var/www/html/repos/rhel-8-for-x86_64-appstream-rpms
    
  5. Set up a web server (e.g., Apache) to serve the repository:

    sudo dnf install -y httpd
    sudo systemctl enable --now httpd
    
  6. Configure firewall to allow HTTP traffic:

    sudo firewall-cmd --add-service=http --permanent
    sudo firewall-cmd --reload
    

Step 2: Client Configuration

With the server set up, the next step is to configure client machines to use this local repository for updates.

For RHEL Clients (using DNF):

  1. Create a repo file on each client:

    sudo tee /etc/yum.repos.d/local-rhel.repo <<EOF
    [local-rhel-baseos]
    name=RHEL BaseOS
    baseurl=http://<your-server-ip>/repos/rhel-8-for-x86_64-baseos-rpms
    enabled=1
    gpgcheck=0
    
    [local-rhel-appstream]
    name=RHEL AppStream
    baseurl=http://<your-server-ip>/repos/rhel-8-for-x86_64-appstream-rpms
    enabled=1
    gpgcheck=0
    EOF
    

For Debian-Based Systems (using APT):

APT doesn't interact directly with RPM package repositories used by RHEL. For APT and Debian-based systems, you would need to set up a mirror for Debian repositories specifically, which typically involves tools like debmirror or apt-mirror.

For openSUSE Systems (using Zypper):

Like APT, Zypper does not use RPM repositories in the format provided for RHEL. To mirror openSUSE repositories, you’ll use rsync to sync openSUSE repositories, and then configure Zypper similarly to DNF using local URLs.

Conclusion

Setting up a centralized update server ensures that all the devices in your network are up-to-date with the latest security patches and updates. This setup reduces the bandwidth cost and increases the security level by maintaining uniformity in software versions across all machines. Depending on your environment, you may need to handle different types of package managers, which requires an understanding of each system’s specific configurations as detailed above. Implementing this within your organization will streamline your update process, making it easier, faster, and more reliable.