Hello,
So sorry for the book. This is a question for Foreman 2.1.2 with Katello 3.16.0.
I’d like to start with a little background, as I think what I’m trying to do with Foreman may be a little “unusual”. Giving the background may help this question make at least a little more sense.
I’m currenting doing a proof-of-concept for using Foreman to provision around 5000 “kiosk” devices across various branch offices. These kiosks have host names which represent its “branch number”, which is a 5-digit number and also a “kiosk” number, which is a two digit number.
So a typical kiosk would have a host name like “00712K01” for kiosk “1” at branch “00712”. This offers several benefits, but it mostly tells support and system administrators where a particular kiosk is. It also decides what IP address the kiosk gets.
I need the ability for end-users to assign these names to kiosks when they are either rebuilt/replaced or new to a branch. I’ve implemented a way of performing this, by adding a snippet in my kickstart which pauses in the %pre
section, brings up a clean tty
and using the Python curses library, prompts for a simple “kiosk number” (the “branch” number is pulled from a host group parameter).
Once the number is entered and the full hostname is assembled, the script dynamically creates a “network.ks” file which is included into the kickstart build. This file is basically generated like so:
network --bootproto=static --device=<%= @host.mac %> --gateway=<%= @host.subnet.gateway %> --ip=${ipAddress} --nameserver=<%= @host.subnet.dns_primary %> --netmask=<%= @host.subnet.mask %> --noipv6 --activate" > /tmp/network.ks
This surprisingly works! The kiosk will boot its OS with the expected hostname and IP address. I have no idea if it is efficient, if its breaking things I don’t know about, or if its even the best way to go about this.
Any who, so now you see what my challenge is and how I’ve been overcoming it. Now let me explain the additional challenge this creates for me.
- I’ve created the products, content views and activation keys for the kiosks.
- I assign the activation key to a particular branch’s host group.
- I boot up a kiosk. It PXE boots into the Foreman discovery environment.
- The kiosk is automatically discovered using a rule, assigned to its appropriate host group and is given the default name of
mac242ffa021773
per the discovery process. It shows up in the “Hosts” section of Foreman asmac242ffa021773.example.com
. - The kiosk boots into the installation media with its kickstart. I input my kiosk number. Using the
network
directive, it sets the hostname to “00712K01” for example. - Now comes time for the kiosk to subscribe to Katello. Based on the
production.log
, it subscribes as00712k01.example.com
, which I suppose I would expect.
2020-10-08T15:53:03 [I|app|50704986] Started POST "/rhsm/consumers?owner=my_company&activation_keys=centos_8_kiosk_key_dev" for 127.0.0.1 at 2020-10-0
8 15:53:03 -0400
2020-10-08T15:53:03 [I|app|50704986] Processing by Katello::Api::Rhsm::CandlepinProxiesController#consumer_activate as JSON
2020-10-08T15:53:03 [I|app|50704986] Parameters: {"type"=>"system", "name"=>"00712k01.example.com", "facts"=>"[FILTERED]", "contentTags"=>[], "role"=>"", "addOns"
=>[], "usage"=>"", "serviceLevel"=>"", "owner"=>"my_company", "activation_keys"=>"centos_8_kiosk_key_dev"}
2020-10-08T15:53:04 [I|aud|50704986] Nic::Managed (163) create event on mac
2020-10-08T15:53:04 [I|aud|50704986] Nic::Managed (163) create event on ip
2020-10-08T15:53:04 [I|aud|50704986] Nic::Managed (163) create event on type Nic::Managed
2020-10-08T15:53:04 [I|aud|50704986] Nic::Managed (163) create event on name 00712k01.example.com
What I find odd however is on the screen of the kiosk, I see it running something like the below:
subscription-manager register --name="mac242ffa021773.example.com" --org='myOrg' --activationkey='centos_8_kiosk_key_dev'
As you can see, it is using the original default name which the discovery plugin gave it.
Once all is done, I end up with two “hosts” in Foreman. One is mac242ffa021773.example.com
and the other is 00712K01.example.com
.
Is there anyway to work around the duplicate entries or is my best bet to delete the original host? These systems call back into Ansible Tower for a provisioning call back, it wouldn’t be too painful to have it simply delete the original object via the API.
Again, if you read all of this, I apologize for the book. It is a weird scenario which I know may not make the most sense. I would love to hear what the community thinks of how I could tackle this new challenge.
Thanks!