Passing variables through cloud-init and subscription-manager

We use Cloudformation to build out our instances in AWS. In the template we define the activation key to use which gets executed by Cloud-Init. All this works fine. We further break down all our hosts into 3 different patching groups. Many releases ago of foreman there were ways to link a Host Collection to an Activation Key but no longer. What I would like to do but not sure this is possible is to pass the patching group name through Cloud-Init to Subscription Manager and then into Foreman. If I can get it this far I can then have a cron job or a Foreman job run looking for the variable. If found add the host to a Host Collection group.

If there is a better way to do something like this I am all for it too.

How comes you think this is not possible anymore? Linking the hostcollection to an activation key is definitely the way to go here. The official docs on activation-keys are here, and on each activation key you should be able to set host collections to regíster the host to.
While we are currently a bit behind on Foreman updates (running 3.9 currently), we have been using the exact workflow for years without any problems.

2 Likes