RLabs: Managing CentOS content with Katello

Foreman has a bunch of plugins but none of them can be compared to Katello, a plugin that is so big, so big, that it changes the way you install and configure Foreman.

Katello is a “plugin” to manage CentOS and RedHat repositories, mirroring content and managing updates and erratas. This is called content management.

In fact, Satellite is the paid and suported version of Foreman/Katello by RedHat, but it suports only RedHat systems while the upstream Foreman/Katello suports both RedHat and CentOS.

You can read the Katello documentation, more specific the content section to understand what we´ll do here.

We´ll create the most basic content, just enough to manage a basic CentOS system.

I suggest you to try doing this stuff in the web interface for the first time, but we´ll use the hammer cli here.

Prepare the content on Katello


First of all, you should prepare katello with some content.

You should really read the official documentation to understand how this works, but I´ll give you a brief explanation:

Hosts will subscribe to Katello using an activation key.
That activation key will provide the host with some products repositories and a content view.
Content view is somewhat like a point in time snapshot of content so that all hosts in the same content view sees the same versions of packages.
product is made of one or more repositories.
Repositories are mirrors of upstream repositories and obey the sync plan policy attached to product.
sync plan is a schedule setting to synchronize the repositories.

We´ll create a simple generic product called “CentOS7”, that will provide everything a basic CentOS7 system would need (updates, EPEL, puppet packages etc). The “CentOS7” activation key will point to this product.
If we want to have some hosts running OpenShift, for example, we should create another product including the OpenShift repositories and create another activation key pointing to the OpenShift product.

Ok ok, this is not all about content management and it is not the best practice. You really should read the official documentation. This was just a brief explanation to understand what we´ll do here.

Create a “daily” sync plan

A sync plan is how frequently a repository is mirrored, and since every repo needs a sync plan attached to it, let´s start creating a daily sync plan.

hammer sync-plan create --interval daily --name Daily --enabled yes --organization RLabs --sync-date "`date -I`"


Create the “CentOS7” product

Create a product named CentOS7 where we´ll put every repo we want the hosts to have.

hammer product create --name CentOS7 --organization RLabs --sync-plan Daily


Create the official repositories attached to the CentOS7 product

Now we´ll create mirrors of the official CentOS7 repositories (base, updates and extra):

hammer repository create --product=CentOS7 --content-type=yum --name "CentOS7 base" --url http://mirror.centos.org/centos/7/os/x86_64 --download-policy on_demand --organization RLabs
hammer repository create --product=CentOS7 --content-type=yum --name "CentOS7 updates" --url http://mirror.centos.org/centos/7/updates/x86_64 --download-policy on_demand --organization RLabs
hammer repository create --product=CentOS7 --content-type=yum --name "CentOS7 extras" --url http://mirror.centos.org/centos/7/extras/x86_64 --download-policy on_demand --organization RLabs


We´ll also create a mirror of Puppet 4 PC1 repo, Katello client tools and EPEL 7, so that managed systems get their packages from the Katello host instead of the Internet.

hammer repository create --product=CentOS7 --content-type=yum --name "Epel 7" --url https://dl.fedoraproject.org/pub/epel/7/x86_64/ --download-policy on_demand --organization RLabs
hammer repository create --product=CentOS7 --content-type=yum --name "Katello Client 3.8" --url https://fedorapeople.org/groups/katello/releases/yum/3.8/client/el7/x86_64 --download-policy on_demand --organization RLabs
hammer repository create --product=CentOS7 --content-type=yum --name "Puppet 4 PC1" --url http://yum.puppetlabs.com/el/7/PC1/x86_64 --download-policy on_demand --organization RLabs


Now you must do the initial sync of these repos:

hammer repository synchronize --name "CentOS7 base" --product "CentOS7" --organization RLabs --async
hammer repository synchronize --name "CentOS7 updates" --product "CentOS7" --organization RLabs --async
hammer repository synchronize --name "CentOS7 extras" --product "CentOS7" --organization RLabs --async
hammer repository synchronize --name "Epel 7" --product "CentOS7" --organization RLabs --async
hammer repository synchronize --name "Katello Client 3.8" --product "CentOS7" --organization RLabs --async
hammer repository synchronize --name "Puppet 4 PC1" --product "CentOS7" --organization RLabs --async

This will make the sync in background, and will take a long time to complete.

You can see the sync progress in Content->Sync status->expand all.

Create and publish a content view

Now you should create and publish a content view with these repositories:

hammer content-view create --name "CentOS7" --organization RLabs --product "CentOS7" --repositories "CentOS7 base,CentOS7 extras,CentOS7 updates,Epel 7,Katello Client 3.8,Puppet 4 PC1"
hammer content-view publish --name "CentOS7" --organization RLabs


Create an activation key

The last step is to create an activation key and add subscriptions to it.

hammer activation-key create --content-view "CentOS7" --name "CentOS7" --lifecycle-environment "Library" --organization RLabs
hammer activation-key add-subscription --name "CentOS7" --subscription-id 1 --organization RLabs


Wait for all the syncs to complete and you will be ready to go.

Registering a content host

On any other host running CentOS7, you can subscripe it to Katello by doing the following steps:

curl --insecure --output katello-ca-consumer-latest.noarch.rpm https://foreman.ext.dc1.lab/pub/katello-ca-consumer-latest.noarch.rpm
yum localinstall katello-ca-consumer-latest.noarch.rpm
subscription-manager register --org="RLabs" --activationkey="CentOS7"

Install katello agent tools:

yum -y install katello-host-tools katello-host-tools-tracer katello-agent

NOTE: DO NOT subscribe the Foreman host to itself.
Why ? Think McFly, Think !


You should see the host in Hosts->Content hosts:

Screenshot 2018-09-28 21.08.36.png


Congratulations, you can now manage package updates using Katello.



3 comentários em “RLabs: Managing CentOS content with Katello

Os comentários estão encerrados.