diff --git a/lib/puppet/application/lookup.rb b/lib/puppet/application/lookup.rb |
index cfbcfab81e..b9e6f22c87 100644 |
--- a/lib/puppet/application/lookup.rb |
+++ b/lib/puppet/application/lookup.rb |
@@ -374,12 +374,9 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License |
|
unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance |
facts = retrieve_node_facts(node, given_facts) |
- if Puppet.settings.set_by_cli?('environment') |
- node = Puppet::Node.new(node, :classes => nil, :parameters => nil, :facts => facts, :environment => Puppet.settings.value('environment')) |
- else |
ni = Puppet::Node.indirection |
tc = ni.terminus_class |
- if options[:compile] |
+ if options[:compile] && !Puppet.settings.set_by_cli?('environment') |
if tc == :plain |
node = ni.find(node, facts: facts) |
else |
@@ -402,10 +399,9 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License |
end |
else |
ni.terminus_class = :plain |
- node = ni.find(node, facts: facts) |
+ node = ni.find(node, facts: facts, environment: Puppet[:environment]) |
ni.terminus_class = tc |
end |
- end |
else |
node.add_extra_facts(given_facts) if given_facts |
end |
|