Adapt default location based on smart proxy used for registration

Problem:
Hi there, I have a simple question : is it possible to automatically assign a location to a host registering on Katello via subscription-manager based on which smart proxy it used ?

As an example, I have 2 sites : ITX and AWS, I have a smart proxy for each, when I register my hosts via subscribe manager and with a smart proxy :

curl --insecure --output katello-ca-consumer-latest.noarch.rpm https://AWS/pub/katello-ca-consumer-latest.noarch.rpmyum localinstall katello-ca-consumer-latest.noarch.rpm 
subcription-manager etc ...

Expected outcome:
My host should be in the AWS location, however, it’s in the ITX one, as it’s the default one for registration
I can override where it’s registered by putting a file like that

# cat /etc/rhsm/facts/location.facts 
{"foreman_location":"AWS"}

But I don’t find that ideal, is there nicer way to achieve that ? like setting default_location to a specific value like “inherit smart proxy” ?

Foreman and Proxy versions:
foreman-1.22.0-1.el7.noarch

Foreman and Proxy plugin versions:
All smart-proxy are 1.22

|foreman-tasks| |0.15.5|
|foreman_ansible||3.0.2|
|foreman_openscap||1.0.1|
|foreman_remote_execution||1.8.2|
|katello||3.12.0|

Distribution and version:
Centos 7

Thank you

@loitho Hey, thanks for writing in! You can set a default location using the Default location setting in the Puppet tab under Settings, but this is globally scoped, so not sure if it will be exactly what you are looking for.

I think you may find the bootstrap script helpful, it looks like it can control Location as well.

Let me know if you have any more questions!

Hi, thanks for your reply

I saw the default_location value, what I’m trying to achieve is just to be able to have the smart proxy location applied to the host registering himself on foreman through the smart proxy.

I would like the “default_location” to be “same as smart proxy used for registration” if that makes sense.
The bootstrap script is quite nice, but in my environment it doesn’t quite works, I’m better simply using the subscription-manager command.
I’ll just update the location.facts file accordingly :slight_smile:

Sorry we couldn’t find a better solution, that sounds like the best bet for now!

That’s okay, I just want to use the most appropriate one :slight_smile:
Thank you again for your replies

1 Like

+1 on this topic.
If it is not possible to set default location based on which smart proxy server subscribed is it possible to do so based on activation key used?
Thank you

@matemikulic can you file an feature request here? https://projects.theforeman.org/projects/katello/issues/new

Sure @John_Mitsch Request opened. Feature #29353: Subscribed server assumes location of smart proxy used to register - Katello - Foreman
Thanks :slight_smile:

1 Like