Commit d72a6bf4 authored by Lamont Granquist's avatar Lamont Granquist
Browse files

CHEF-5211: fix configure hostname guessing

ohai[:fqdn] depends on DNS and may be nil.  change the algorithm to use
the hostnaome of the machine as a fallback using the same algorithm
that Chef::Client uses for guessing the node_name of a host.
parent 2e9367e6
......@@ -156,7 +156,7 @@ EOH
o.require_plugin 'os'
o.require_plugin 'hostname'
o[:fqdn] || 'localhost'
o[:fqdn] || o[:machinename] || o[:hostname] || 'localhost'
def config_file
......@@ -32,6 +32,7 @@ describe "knife configure" do
it "loads the fqdn from Ohai" do
knife_configure =
expect(knife_configure.guess_servername).to eql(ohai[:fqdn])
hostname_guess = ohai[:fqdn] || ohai[:machinename] || ohai[:hostname] || 'localhost'
expect(knife_configure.guess_servername).to eql(hostname_guess)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment