Importing a Katello RedHat manifest using API

Is it possible to import a manifest using the API?

I am trying to completely automate usage of Foreman + Katello and right now all I am missing is importing the manifest to get the RedHat Subscriptions in before provisioning.

Thank you!

Distribution and version:

Foreman 2.4 and Katello 4.0 on RHEL 7.0

Hey,

yeah, sure, this is possible.

the API itself is documented here: API documentation

And we also have Ansible modules to do so: theforeman.foreman.subscription_manifest – Manage Subscription Manifests — Foreman Ansible Modules documentation

What are you using for automation?

1 Like

Great thank you, was looking for an API with Manifest in it, didn’t think about the Subscription one.

We are looking to automate the deployment of a 6 blade MEC platform with integrated switches. Would like the user to input it’s Manifest and then we would automate deployment of RHEL 8.3.

Thinking of using the API through ‘python-foreman’ right now, but will look into the Ansible playbooks. Could use Python Ansible-Runner instead and script calls to hammer.

I feel like direct API calls is more straight forward, but using Ansible would make the actual calls run locally on the Foreman VM so that could provide useful from a namespace perspective accessing host network not available from the outside.

Well, Ansible can run anywhere, but also on the Foreman host, yeah.

If you want to use Python directly, have a look at apypie – that’s the library we use for the Ansible modules. It simplifies building the requests to the API by parsing the published API docs on the Foreman server, instead of having an own copy of the allowed parameters/requests.

What is the sequence of events to get a Manifest tied to HostGroup?

Since the HostGroup references the ActivationKeys by name, if I already have a HostGroup expecting an ActivationKey ‘RHEL_8_3’, I suppose it would be:

  • Upload Manifest
  • Create ActivationKey with name ‘RHEL_8_3’ and add repos from the Manifest

Would that be enough for the HostGroup to use that new Manifest to provision the hosts and activate/apply erratas.

I have it setup right now and working, but I am wondering if that would be the only 2 steps to change to a different Manifest.

Just asking in case you know, I will be trying it soon and will find out if it’s enough or not.

It’s a tad more complicated :slight_smile:

A manifest is just a certificate stating “you have access to the following subscriptions and products” (and their quantities).
So after uploading a Manifest, you will have to do the following steps

  • enable one or multiple Red Hat repositories (in the UI, or the repository_set Ansible module/API)
  • sync those
  • create an activation key that either has the right subscriptions attached, or you use Simple Content Access (preferred these days)
  • create a HG and assign that AK there, plus the “Default Organization View” content view (or one that you have created).

This is probably better described in our Content Management Guide :slight_smile:

Pretty close to what I thought.

I already have all of that setup and working, I have added RedHat repos and synced then, I have created Product, I have a Content View that is linked to my HostGroup and an ActivationKey referenced from my HostGroup.

What I want to do is delete the ActivationKey and the Manaifest and then get back to a working setup.

I just saw that the AK links to the ContentView, so I will need to know my ContentView ID when I recreate it.

Hopefully I don’t need to change my HG if I use the same name for the new AK.

Thank you, will let you know how it goes.