Method: Puppet::Node::Environment#modules
- Defined in:
- lib/puppet/node/environment.rb
#modules ⇒ Array<Puppet::Module>
Note:
If multiple modules with the same name are present they will both be added, but methods like #module and #module_by_forge_name will return the first matching entry in this list.
Note:
This value is cached so that the filesystem doesn’t have to be re-enumerated every time this method is invoked, since that enumeration could be a costly operation and this method is called frequently. The cache expiry is determined by Puppet[:filetimeout].
Return all modules for this environment in the order they appear in the modulepath.
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 |
# File 'lib/puppet/node/environment.rb', line 344 def modules if @modules.nil? module_references = [] project = Puppet.lookup(:bolt_project) { nil } seen_modules = if project && project.load_as_module? module_references << project.to_h { project.name => true } else {} end modulepath.each do |path| Puppet::FileSystem.children(path).map do |p| Puppet::FileSystem.basename_string(p) end.each do |name| next unless Puppet::Module.is_module_directory?(name, path) warn_about_mistaken_path(path, name) unless seen_modules[name] module_references << { :name => name, :path => File.join(path, name) } seen_modules[name] = true end end end @modules = module_references.filter_map do |reference| Puppet::Module.new(reference[:name], reference[:path], self) rescue Puppet::Module::Error => e Puppet.log_exception(e) nil end end @modules end |