New hosts are put in wrong content view

Problem:
We have an automated script-based process that creates new hosts and registers them with our Foreman server with subscription-manager. The details are handled by Chef, so there is no manual intervention needed when we spin up a host. The problem is that every new host we create gets dumped into the content view Default Organization View, and ends up with the wrong package repositories. We have three other content views set up (one each for CentOS, Alma Linux, and Fedora), but after the host shows up in Foreman we need to manually move it from Default Organization View to the correct one.

I’ve tried editing Default Organization View with hammer to give it a better set of repositories, but I’m told that “The default content view cannot be edited, published, or deleted.”

Apparently there’s no subscription-manager command for setting content view.

Is there a way we can automate which content view a new host gets assigned to when it first connects to Foreman?

Foreman and Proxy versions:
Foreman 3.4

Foreman and Proxy plugin versions:
Katello 4.6
rubygem-hammer_cli 3.4

Distribution and version:
Alma Linux 8.7

How exactly do you create the hosts?

How exactly do you register?

Usually, you would use activation keys to register hosts and set the initial content view and repository set.

Yup, I just figured this out. We were using an activation key that was associated with Default Organization View. I’m creating a new separate activation key for each content view, which should solve the problem.