opscode/ohai — pull request #184 by ichilton (2013-08-29 23:23:10+00:00)
Title: Use hostname as fqdn if hostname is a fqdn and hostname --fqdn doesn't work

If a node has a FQDN in /etc/hostname (which some providers, like Digital Ocean do if you use the fqdn as the name when creating the instance):

```
root@gw1:~# cat /etc/hostname
gw1.mydomain.com

root@gw1:~# cat /etc/hosts |head -2
127.0.0.1 localhost gw1

root@gw1:~#

So therefore the FQDN & domain name don't work:

root@gw1:~# hostname -s
gw1

root@gw1:~# hostname -d
hostname: Name or service not known

root@gw1:~# hostname -f
hostname: Name or service not known

And therefore Ohai doesn't know what's going on:

root@gw1:~# ohai |grep hostname
"hostname": "gw1",
root@gw1:~# ohai |grep domain
root@gw1:~# ohai |grep fqdn
root@gw1:~#
```

The attached commit fixes that by using hostname as the fqdn if the hostname looks like a FQDN.