diff options
author | James Turnbull <james@lovedthanlost.net> | 2008-02-23 08:41:24 +1100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-02-23 08:41:24 +1100 |
commit | 5d35bc5904a09bc07a11039500c59021bafaee7e (patch) | |
tree | 5d0980bfb8ce1a2d9d5e244046846617a040a3cb | |
parent | 7976015389149defd7f135a859ab11b94e6aad11 (diff) | |
download | puppet-5d35bc5904a09bc07a11039500c59021bafaee7e.tar.gz puppet-5d35bc5904a09bc07a11039500c59021bafaee7e.tar.xz puppet-5d35bc5904a09bc07a11039500c59021bafaee7e.zip |
Fixes #1078 and includes new test
-rw-r--r-- | lib/puppet/network/client/master.rb | 6 | ||||
-rwxr-xr-x | test/network/client/master.rb | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 6d1a0235f..390f3d4e2 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -40,8 +40,10 @@ class Puppet::Network::Client::Master < Puppet::Network::Client facts["clientversion"] = Puppet.version.to_s # And add our environment as a fact. - facts["environment"] = Puppet[:environment] - + unless facts.include?("environment") + facts["environment"] = Puppet[:environment] + end + facts end diff --git a/test/network/client/master.rb b/test/network/client/master.rb index 696d08bfd..67c47fa6d 100755 --- a/test/network/client/master.rb +++ b/test/network/client/master.rb @@ -211,6 +211,24 @@ end "Lost value to hostname") end + # Make sure that setting environment by fact takes precedence to configuration + def test_setenvironmentwithfact + name = "environment" + value = "test_environment" + + Puppet[:filetimeout] = -1 + Puppet[:factsource] = tempfile() + Dir.mkdir(Puppet[:factsource]) + file = File.join(Puppet[:factsource], "#{name}.rb") + File.open(file, "w") do |f| + f.puts %{Facter.add("#{name}") do setcode { "#{value}" } end } + end + + Puppet::Network::Client.master.getfacts + + assert_equal(value, Puppet::Network::Client.master.facts[name]) + end + # Make sure we load all facts on startup. def test_loadfacts dirs = [tempfile(), tempfile()] |