class Puppet::Util::CommandLine::ApplicationSubcommand
@api private
Public Class Methods
new(subcommand_name, command_line)
click to toggle source
# File lib/puppet/util/command_line.rb 108 def initialize(subcommand_name, command_line) 109 @subcommand_name = subcommand_name 110 @command_line = command_line 111 end
Public Instance Methods
run()
click to toggle source
# File lib/puppet/util/command_line.rb 113 def run 114 # For most applications, we want to be able to load code from the modulepath, 115 # such as apply, describe, resource, and faces. 116 # For agent and device in agent mode, we only want to load pluginsync'ed code from libdir. 117 # For master, we shouldn't ever be loading per-environment code into the master's 118 # ruby process, but that requires fixing (#17210, #12173, #8750). So for now 119 # we try to restrict to only code that can be autoloaded from the node's 120 # environment. 121 122 # PUP-2114 - at this point in the bootstrapping process we do not 123 # have an appropriate application-wide current_environment set. 124 # If we cannot find the configured environment, which may not exist, 125 # we do not attempt to add plugin directories to the load path. 126 unless @subcommand_name == 'master' || @subcommand_name == 'agent' || (@subcommand_name == 'device' && (['--apply', '--facts', '--resource'] - @command_line.args).empty?) 127 configured_environment = Puppet.lookup(:environments).get(Puppet[:environment]) 128 if configured_environment 129 configured_environment.each_plugin_directory do |dir| 130 $LOAD_PATH << dir unless $LOAD_PATH.include?(dir) 131 end 132 133 Puppet::ModuleTranslations.load_from_modulepath(configured_environment.modules) 134 Puppet::ModuleTranslations.load_from_vardir(Puppet[:vardir]) 135 136 # Puppet requires Facter, which initializes its lookup paths. Reset Facter to 137 # pickup the new $LOAD_PATH. 138 Facter.reset 139 end 140 end 141 142 app = Puppet::Application.find(@subcommand_name).new(@command_line) 143 app.run 144 end