I’m adding a new repository to my Foreman environment. I’ve created the Product and synced the repo and I’ve added this product to my various Content Views (of which I have now published new versions) and Activation Keys. However, when I go to one of my existing hosts and do a yum clean all and yum repolist, I do not see the new repository. The only way I can get it to show up is to open the individual hosts and go into Content, Subscriptions, and then manually add the new Product to that particular host. Although this obviously works, it is very time consuming if you’ve got a lot of hosts. I’m thinking there’s got to be a way to automate this, but I figure I must have missed a step somewhere. Any ideas?
In your activation keys you need to go into Subscriptions and enable the subscription of the relevant product. Once you do that all future content hosts that are registered with this new activation key will automatically get subscribed to your product.
I get that part, but what about existing hosts? One thought I had was to just re-register each one of my existing hosts and let the activation key with the new product in it take care of it. Is that my best bet?
I know of two options you have here for existing hosts.
Option one: Automate what you would click on the foreman side of things.
This essentially means you add the subscription to each of the hosts in your CVs. You can either use hammer for this via
hammer host subscription attach and enable the repository via
hammer host subscription content-override if necessary or use the correlating API endpoints for this (see http:///apidoc/v2/host_subscriptions.html for details)
Option two: You can automate it on the clientside. Subscrition manager has the ability to attach subscritions to itself via
subscription-manager attach --pool <poolid>. You can find the pool ID of your product via
subscription-manager list --all``´. After that, you can enable the repos in that product via subscription-manager repos --enable ```. Since this is simple client-side shell stuff, you could automate this via your favorite orchestration solution, e.g. Foreman REx or Ansible or a plain simple shell script that does SSH to each machine.
You can also use something like → Bulk Updating Content Hosts’ Subscriptions
If you want it applied to existing hosts and update em en masse.