@@ -106,7 +106,7 @@ def initialize(subcommand_name, command_line)
106106 def run
107107 # For most applications, we want to be able to load code from the modulepath,
108108 # such as apply, describe, resource, and faces.
109- # For agent and device, we only want to load pluginsync'ed code from libdir.
109+ # For agent and device in agent mode , we only want to load pluginsync'ed code from libdir.
110110 # For master, we shouldn't ever be loading per-environment code into the master's
111111 # ruby process, but that requires fixing (#17210, #12173, #8750). So for now
112112 # we try to restrict to only code that can be autoloaded from the node's
@@ -116,7 +116,7 @@ def run
116116 # have an appropriate application-wide current_environment set.
117117 # If we cannot find the configured environment, which may not exist,
118118 # we do not attempt to add plugin directories to the load path.
119- unless [ 'master' , 'agent' , 'device' ] . include? @subcommand_name
119+ unless @subcommand_name == 'master' || @subcommand_name == 'agent' || ( @subcommand_name == 'device' && ( [ '--apply' , '--facts' , '--resource' ] - @command_line . args ) . empty? )
120120 if configured_environment = Puppet . lookup ( :environments ) . get ( Puppet [ :environment ] )
121121 configured_environment . each_plugin_directory do |dir |
122122 $LOAD_PATH << dir unless $LOAD_PATH. include? ( dir )
0 commit comments