summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-05-17 14:55:57 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit970fd8764a248e80e9a0700e541867d646a1e2e3 (patch)
treedd0ae989b9a712e05991981298093ae77ff34771 /lib
parentcce63d86d7ce3965e58d8e57ff19533a3f21b4eb (diff)
downloadpuppet-970fd8764a248e80e9a0700e541867d646a1e2e3.tar.gz
puppet-970fd8764a248e80e9a0700e541867d646a1e2e3.tar.xz
puppet-970fd8764a248e80e9a0700e541867d646a1e2e3.zip
Fixing #3791 - client environment is used
Node#environment wasn't being set correctly, in that it had to have the right answer out of the gate or it was never corrected. It was lazy-binding in 0.25 but I managed to make it no longer that way. This resulted in the environment basically not being set during compilation, so the default server environment was always used. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/node.rb22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/puppet/node.rb b/lib/puppet/node.rb
index 721c9f586..5115e7fb1 100644
--- a/lib/puppet/node.rb
+++ b/lib/puppet/node.rb
@@ -9,13 +9,28 @@ class Puppet::Node
# the node sources.
extend Puppet::Indirector
+ # Adds the environment getter and setter, with some instance/string conversion
+ include Puppet::Node::Environment::Helper
+
# Use the node source as the indirection terminus.
indirects :node, :terminus_setting => :node_terminus, :doc => "Where to find node information.
A node is composed of its name, its facts, and its environment."
- attr_accessor :name, :classes, :source, :ipaddress, :environment
+ attr_accessor :name, :classes, :source, :ipaddress
attr_reader :time, :parameters
+ def environment
+ return super if @environment
+
+ if env = parameters["environment"]
+ self.environment = env
+ return super
+ end
+
+ # Else, return the default
+ Puppet::Node::Environment.new
+ end
+
def initialize(name, options = {})
unless name
raise ArgumentError, "Node names cannot be nil"
@@ -34,8 +49,9 @@ class Puppet::Node
@parameters = options[:parameters] || {}
- env = options[:environment] || @parameters[:environment] || @parameters["environment"] || Puppet::Node::Environment.new
- @environment = env.is_a?(String) ? Puppet::Node::Environment.new(env) : env
+ if env = options[:environment]
+ self.environment = env
+ end
@time = Time.now
end