diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2013-08-27 17:17:21 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2013-08-27 17:17:21 -0700 |
commit | cfe1bfc51893ca6f5c654ebe91794a7d6b61d944 (patch) | |
tree | 9867d54769fdf47036762b7fbf8a99b432d3020a | |
parent | 5f2e9256a97163857112be6ac5fc2da7fed8b078 (diff) | |
download | ohai-cfe1bfc51893ca6f5c654ebe91794a7d6b61d944.tar.gz |
fall back to hostname if hostname -f broken
stop stabbing ourselves in the eye.
in darwin, openbsd, netbsd, freebsd, etc we just use 'hostname'
which is whatever is set on the box. on linux, we're trying to be
clever and using 'hostname -f' which is in some sense more canonically
correct way to resolve the hostname, but requires doing DNS lookups.
since we don't bother with that on other operating systems, this is
clearly not a requirement, however, and if it fails, we can fall
back to hostname. if people have flaky DNS going on, they need to
make sure their hostnames on the box match the name in DNS and/or they
need to be setting their node_name's correctly in config.rb -- either
way i'm perfectly happy creating that problem via solving this one.
-rw-r--r-- | lib/ohai/plugins/linux/hostname.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ohai/plugins/linux/hostname.rb b/lib/ohai/plugins/linux/hostname.rb index fe77b3bf..3eb8d374 100644 --- a/lib/ohai/plugins/linux/hostname.rb +++ b/lib/ohai/plugins/linux/hostname.rb @@ -24,7 +24,8 @@ Ohai.plugin do begin fqdn from("hostname --fqdn") rescue - Ohai::Log.debug("hostname -f returned an error, probably no domain is set") + Ohai::Log.debug("hostname -f returned an error, falling back to hostname") + fqdn from("hostname") end end end |