[Pkg-puppet-devel] [facter] 117/180: (FACT-179) Resolve fqdn fact when domain is empty

Stig Sandbeck Mathisen ssm at debian.org
Mon Jun 30 15:06:38 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit e2b8fbca5372ff1c8e3600b1441a94e3800569ac
Author: Branan Purvine-Riley <branan at puppetlabs.com>
Date:   Mon Jun 2 15:14:09 2014 -0700

    (FACT-179) Resolve fqdn fact when domain is empty
    
    Previously, the fqdn fact would only resolve if both hostname and
    domain were available on a host. Having a nil result when `hostname
    -f` would return just the hostname is surprising to users, and we
    should instead simply return the hostname when we cannot resolve a
    domain.
---
 lib/facter/fqdn.rb     |  2 ++
 spec/unit/fqdn_spec.rb | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/lib/facter/fqdn.rb b/lib/facter/fqdn.rb
index 68597f3..48d0953 100644
--- a/lib/facter/fqdn.rb
+++ b/lib/facter/fqdn.rb
@@ -15,6 +15,8 @@ Facter.add(:fqdn) do
     domain = Facter.value(:domain)
     if host and domain
       [host, domain].join(".")
+    elsif host
+      host
     else
       nil
     end
diff --git a/spec/unit/fqdn_spec.rb b/spec/unit/fqdn_spec.rb
new file mode 100644
index 0000000..57a1c2a
--- /dev/null
+++ b/spec/unit/fqdn_spec.rb
@@ -0,0 +1,16 @@
+#! /usr/bin/env ruby
+
+require 'spec_helper'
+
+describe "fqdn fact" do
+  it "should concatenate hostname and domain" do
+    Facter.fact(:hostname).stubs(:value).returns("foo")
+    Facter.fact(:domain).stubs(:value).returns("bar")
+    Facter.fact(:fqdn).value.should == "foo.bar"
+  end
+  it "should return hostname when domain is nil" do
+    Facter.fact(:hostname).stubs(:value).returns("foo")
+    Facter.fact(:domain).stubs(:value).returns(nil)
+    Facter.fact(:fqdn).value.should == "foo"
+  end
+end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list