Skip to content

Commit 1c9bc36

Browse files
author
Nuo Yan
committed
run chef-client in the environment if the user specifies :environment in the client.rb file
1 parent dae731a commit 1c9bc36

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

‎chef/lib/chef/client.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ def node_name
210210
# === Returns
211211
# node<Chef::Node>:: Returns the created node object, also stored in @node
212212
def build_node
213-
Chef::Log.debug("Building node object for #{@node_name}")
213+
Chef::Log.debug("Building node object for #{node_name}")
214214

215215
if Chef::Config[:solo]
216216
@node = Chef::Node.build(node_name)

‎chef/lib/chef/node.rb‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,9 @@ def self.exists?(nodename, couchdb)
555555
end
556556

557557
def self.find_or_create(node_name)
558-
load(node_name)
558+
node = load(node_name)
559+
node.chef_environment(Chef::Config[:environment]) unless Chef::Config[:environment].nil? || Chef::Config[:environment].chop.empty?
560+
node
559561
rescue Net::HTTPServerException => e
560562
raise unless e.response.code == '404'
561563
node = build(node_name)

0 commit comments

Comments
 (0)