Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why write to kernel.hostname? #67

Open
dgarstang opened this issue Apr 10, 2018 · 1 comment
Open

Why write to kernel.hostname? #67

dgarstang opened this issue Apr 10, 2018 · 1 comment

Comments

@dgarstang
Copy link

Why does this cookbook write kernel.hostname to sysctl.conf? It seems that any value set here overrides the normal locally configured host name.

Running this before kernel.hostname was added to sysctl.conf would return the FQDN.
python -c 'import socket ; print socket.gethostname()'

After kernel.hostname added to sysctl.conf, then above command would return only what was set in kernel.hostname, which was the short name. As a result, many applications like python, php and splunk would get the short host name instead of the long host name.

To make matters worse, it appears you can't unset this kernel setting. If you try an write an empty value with the sysctl command:

[root@stage1 kernel]# sysctl -w kernel.hostname=""
sysctl: malformed setting "kernel.hostname="

if you write an empty value to /proc/sys/kernel/hostname, it mucks up the whole system.

[root@stage1 kernel]# echo "" > /proc/sys/kernel/hostname
[root@stage1 kernel]# hostname -f
hostname: Name or service not known

sysctl -p for a reload doesn't work either. If you remove the entry from /etc/sysctl.conf, and then run sysctl -p, then it's still there!

[root@stage1 kernel]# sysctl -p
kernel.domainname = y.com
[root@stage1 kernel]# sysctl -a | grep hostname
fs.nfs.nsm_use_hostnames = 0
kernel.hostname = w1

It looks like we may to reboot ALL our servers because of this.

@rjhornsby
Copy link

rjhornsby commented Nov 5, 2018

Indeed. It's definitely an unexpected approach. I've been doing this for a long time, and I've never come across using kernel/sysctl parameters to set the hostname.

Having a hard time getting this cookbook to properly set the domain name (FQDN), and I suspect it's related to this issue.

Edit: there's a native chef resource, hostname, that should eliminate the need for this cookbook.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants