Introduction:
In this tutorial, we are going to learn how to sync & store CentOS 8 BaseOS & AppStream repositories on Foreman Katello & Red Hat Satellite. Foreman is used for life cycle management of physical and virtual systems. It is an open source application use for provisioning.
Foreman is the basic foundation form which Red Hat Satellite’s core functionality is derived. Katello is a Foreman plug-in for subscription & repository management. It helps you to assist with storing repositories on your local system and provides a means to subscribe to those repositories & download content.
In case, you don’t have Foreman/Red Hat Satellite, you can follow this tutorial;
How To Create CentOS 8 Local Repository Mirrors With Rsync & Nginx
Now, move towards our tutorial,
Step 1: Creating a Product
Create a product on CLI or from the web console.
From CLI:
List organizations
hammer organization list
Create Product
hammer product create --organization-id 1 \
From Web Console
Go to Products> Create Product
Type your product details & click the save button to finish creating your product.
Step 2: Import CentOS 8 GPG Key
From CLI
mkdir /etc/pki/rpm-gpg/import/
cd /etc/pki/rpm-gpg/import/
wget https://www.centos.org/keys/RPM-GPG-KEY-CentOS-Official
hammer gpg create --organization-id 1 \
--key "RPM-GPG-KEY-CentOS-Official" \
--name "RPM-GPG-KEY-CentOS-8"
Navigate to Content > Credential > New Content Credential to create key from Web Console.
Provide all information like -Name, Type & Paste the key content or use the below button to upload.
Step 3: Create Repositories
Now you can add the new repositories to the newly created product.
Hammer CLI
BaseOS repository
hammer repository create
--organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 Base RPMS" \ --label "CentOS_8_Base_RPMS" \
--content-type "yum" \ --download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \ --url "http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/" \
--mirror-on-sync "no"
AppStream repository
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 AppStream RPMS" \
--label "CentOS_8_AppStream_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/" \
--mirror-on-sync "no"
PowerTools repository
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 PowerTools RPMS" \
--label "CentOS_8_PowerTools_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/" \
--mirror-on-sync "no"
Centosplus repository
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 centosplus RPMS" \
--label "CentOS_8_centosplus_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/" \
--mirror-on-sync "no"
Extras repository
hammer repository create --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--name "CentOS 8 extras RPMS" \
--label "CentOS_8_extras_RPMS" \
--content-type "yum" \
--download-policy "on_demand" \
--gpg-key "RPM-GPG-KEY-CentOS-8" \
--url "http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/" \
--mirror-on-sync "no"
Run the following command to list & view the repositories in the Product.
hammer repository list
--organization-id 1
--product "CentOS Linux for x86_64"
$ hammer repository list --organization-id 1 --product "CentOS 8 Linux for x86_64"
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
ID | NAME | PRODUCT | CONTENT TYPE | URL
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
65 | CentOS 8 AppStream RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/
64 | CentOS 8 Base RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/
67 | CentOS 8 centosplus RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/
68 | CentOS 8 extras RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/
66 | CentOS 8 PowerTools RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
From Web Console
We can achieve the same from the Foreman / Satellite web dashboard.
To achieve this go to Products > Repositories.
Step 4: Sync Repositories
Now you are able to Sync your repositories to your local Satellite / Katello server.
From CLI
list repositories
$ hammer repository list --organization-id 1 --product "CentOS 8 Linux for x86_64"
---|--------------------------|---------------------------|--------------|--------------------------------------------------------------- ID | NAME | PRODUCT | CONTENT TYPE | URL
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
65 | CentOS 8 AppStream RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/AppStream/x86_64/os/
64 | CentOS 8 Base RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/BaseOS/x86_64/os/
67 | CentOS 8 centosplus RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/centosplus/x86_64/os/
68 | CentOS 8 extras RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/extras/x86_64/os/
66 | CentOS 8 PowerTools RPMS | CentOS 8 Linux for x86_64 | yum | http://centos.mirror.liquidtelecom.com/8/PowerTools/x86_64/os/
---|--------------------------|---------------------------|--------------|---------------------------------------------------------------
Look over th IDs then loop through to sync the repositories.
for i in $(seq 64 68); do \
hammer repository synchronize --async --organization-id 1 \
--product "CentOS 8 Linux for x86_64" \
--id "$i"; \
done
Make sure status is working properly.
$ hammer product list --name "CentOS 8 Linux for x86_64" --organization-id 1
---|---------------------------|----------------------------------------|---------------|--------------|------------------ ID | NAME | DESCRIPTION | ORGANIZATION | REPOSITORIES | SYNC STATE
---|---------------------------|----------------------------------------|---------------|--------------|------------------
37 | CentOS 8 Linux for x86_64 | Repositories for CentOS 8 Linux x86_64 | Mycompany LTD | 5 | Syncing Complete.
---|---------------------------|----------------------------------------|---------------|--------------|------------------
You can also run a sync from web console dashboard.
Step 5: Create a Content View
Follow this command to create content view
hammer content-view create --organization-id 1 \
--name "CentOS_8" \
--description "Content view for CentOS 8"
Add repositories to Content View
for i in $(seq 64 68); do \
hammer content-view add-repository --organization-id 1 \
--name "CentOS_8" \
--product "CentOS 8 Linux for x86_64" \
--repository-id "$i"; \
done
Step 7: Publish Content View
hammer content-view publish --organization-id 1 \
--name "CentOS_8" \
--description "Publishing repositories"
Create an Activation Key
$ hammer lifecycle-environment list --organization-id 1
---|---------|------
ID | NAME | PRIOR
---|---------|------
1 | Library |
---|---------|------
$ hammer activation-key create --organization-id 1 \
--name "centos8" \
--description "CentOS 8 Activation Key" \
--lifecycle-environment "Library" \
--content-view "CentOS_8" \
--unlimited-hosts
$ hammer activation-key list --organization-id 1
---|-----------------|------------------|-----------------------|--------------------------
ID | NAME | HOST LIMIT | LIFECYCLE ENVIRONMENT | CONTENT VIEW ---|-----------------|------------------|-----------------------|--------------------------
1 | centos7 | 0 of Unlimited | | 2 | centos8 | 0 of Unlimited | | ---|-----------------|------------------|-----------------------|--------------------------
Step 9: Add Subscription to Activation Key
hammer subscription list --organization-id 1
hammer activation-key add-subscription --organization-id 1 \
--name "centos8" \
--quantity "1" \
--subscription-id "164"
Where 164 is the id of the subscription shown by the last command.
Step 10: Subscribe CentOS 8 Machine to Satellite / Foreman (Katello)
Our repositories are now ready to be consumed by CentOS clients.
Follow this guide to learn;
How To Subscribe CentOS Server to Katello/Foreman
Congratulations! You’ve all done. If have any queries regarding this tutorial guide, feel free to ask.