Sha256: 8ab1253d40dc52edd93e280d1fb15137ba7fc4bd141214b6ac2fd59ba52572f6

Contents?: true

Size: 1.26 KB

Versions: 150

Compression:

Stored size: 1.26 KB

Contents

class Puppet::InfoService::TaskInformationService
  require 'puppet/module'

  def self.tasks_per_environment(environment_name)
    # get the actual environment object, raise error if the named env doesn't exist
    env = Puppet.lookup(:environments).get!(environment_name)
    env.modules.map do |mod|
      mod.tasks.map do |task|
        {:module => {:name => task.module.name}, :name => task.name}
      end
    end.flatten
  end

  def self.task_data(environment_name, module_name, task_name)
    # raise EnvironmentNotFound if applicable
    Puppet.lookup(:environments).get!(environment_name)

    pup_module = Puppet::Module.find(module_name, environment_name)
    if pup_module.nil?
      raise Puppet::Module::MissingModule, _("Module %{module_name} not found in environment %{environment_name}.") %
                                            {module_name: module_name, environment_name: environment_name}
    end

    task = pup_module.tasks.find { |t| t.name == task_name }
    if task.nil?
      raise Puppet::Module::Task::TaskNotFound, _("Task %{task_name} not found in module %{module_name}.") %
                                                 {task_name: task_name, module_name: module_name}
    end

    {:metadata_file => task.metadata_file, :files => task.files}
  end
end

Version data entries

150 entries across 150 versions & 2 rubygems

Version Path
puppet-5.5.22 lib/puppet/info_service/task_information_service.rb
puppet-5.5.22-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.22-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.22-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-5.5.21 lib/puppet/info_service/task_information_service.rb
puppet-5.5.21-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.21-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.21-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-5.5.20 lib/puppet/info_service/task_information_service.rb
puppet-5.5.20-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.20-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.20-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-5.5.19 lib/puppet/info_service/task_information_service.rb
puppet-5.5.19-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.19-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.19-universal-darwin lib/puppet/info_service/task_information_service.rb
puppet-5.5.18 lib/puppet/info_service/task_information_service.rb
puppet-5.5.18-x86-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.18-x64-mingw32 lib/puppet/info_service/task_information_service.rb
puppet-5.5.18-universal-darwin lib/puppet/info_service/task_information_service.rb