localhost.localdomain instead of the hostname when registered in Anaconda using a Kickstart file
Hello,
I recently automated RHEL 8 installation with a Kickstart file. Everything works as expected except the registration. I always get a system named localhost.localdomain in Red Hat Subscription Management. In the network table of system facts, the hostname is always localhost.localdomain, and ipv4_address is 127.0.0.1.
There is this static
network
network --bootproto=static --device=ens192 --gateway=
--ip= --nameserver= --netmask=255.255.252.0 --noipv6 --activate network --hostname=myhostname
I also tried this in one network command, but the result was the same.
The
rhsm
rhsm --organization="
" --activation-key=" "
When I manually unregister that system and register it again, its hostname is correct. When I do the same installation procedure manually, everything is fine. I’m wondering if the timing makes the difference here.
I went through the syslog and found a few interesting events:
# less /var/log/anaconda/syslog | grep 'localhost.localdomain\|myhostname' 14:26:19,528 INFO NetworkManager:
[1637245579.5285] policy: set-hostname: set hostname to 'localhost.localdomain' (no hostname found) 14:26:19,529 INFO systemd-hostnamed:Changed host name to 'localhost.localdomain' 14:26:37,391 WARNING org.fedoraproject.Anaconda.Modules.Network:DEBUG:anaconda.modules.network.network:Hostname is set to myhostname 14:26:54,572 INFO rhsm-service: INFO [subscription_manager.managerlib:72] Consumer created: localhost.localdomain (dc452966-de3e-4177-a970-9a1c45ba9850) 14:35:19,094 INFO systemd-hostnamed:Changed host name to 'myhostname' 14:35:19,097 WARNING org.fedoraproject.Anaconda.Modules.Network:DEBUG:anaconda.modules.network.network:Current hostname is set to myhostname 14:35:19,099 WARNING org.fedoraproject.Anaconda.Modules.Network:DEBUG:anaconda.modules.network.network:Current hostname changed to myhostname
At 14:26:19,529,
system-hostnamed
localhost.localdomain
rhsm-service
localhost.localdomain
Finally, at 14:35:19,094,
system-hostnamed
myhostname
Anaconda.Modules.Network
I also searched the log for initial
rhsm.service
# less /var/log/anaconda/syslog | grep rhsm-service 14:26:32,920 INFO rhsm-service:WARNING [rhsm.logutil:170] logging already initialized 14:26:37,925 INFO rhsm-service:DEBUG [rhsmlib.file_monitor:305] Enabling watcher: /etc/rhsm/rhsm.conf again 14:26:45,355 INFO rhsm-service:DEBUG [rhsmlib.dbus.objects.config:120] Setting new configuration values: {'server.hostname': 'subscription.rhsm.redhat.com', 'server.proxy_hostname': '', 'server.proxy_port': '-1', 'server.proxy_user': '', 'server.proxy_password': '', 'rhsm.baseurl': 'https://cdn.redhat.com'} 14:26:45,356 INFO rhsm-service:DEBUG [rhsmlib.file_monitor:294] Temporary disabled watcher: /etc/rhsm/rhsm.conf for 5 seconds
server.hostname
localhost.localdomain
So the main questions are:
1. Why do these two services/modules report different hostname values?
2. Is there a mistake in my Kickstart file?
I found a workaround. With some extra commands in the
%post
%post subscription-manager remove --all subscription-manager unregister subscription-manager clean subscription-manager register --org="
" --activationkey=" " %end
I’m getting a system with the correct name and network values in Red Hat Subscription Management.
Initially, I used the
clean
"Removes all local system and subscription data without affecting the server (effectively doing an unregister and remove)"
Please help me understand the whole process because I ran out of ideas on how to fix it without the workaround.
Responses