lib/bolt/pal.rb
# PALError is used to convert errors from executing puppet code into
# Bolt::Errors
PALError is used to convert errors from executing puppet code into
Bolt::Errors
PALError is used to convert errors from executing puppet code into Bolt :: Errors
def lookup(key, targets, inventory, executor, plan_vars: {})
      in_plan_compiler(executor, inventory, nil) do |compiler|
        compiler.call_function('apply_prep', targets)
      end
      overrides = {
        bolt_inventory: inventory,
        bolt_project:   @project
      }
      results = targets.map do |target|
        node = Puppet::Node.from_data_hash(
          'name'       => target.name,
          'parameters' => { 'clientcert' => target.name }
        )
        trusted = Puppet::Context::TrustedInformation.local(node).to_h
        env_conf = {
          modulepath: @modulepath.full_modulepath,
          facts:      target.facts
        }
        interpolations = {
          variables:        plan_vars,
          target_variables: target.vars
        }
        with_puppet_settings do
          Puppet::Pal.in_tmp_environment(target.name, **env_conf) do |pal|
            Puppet.override(overrides) do
              Puppet.lookup(:pal_current_node).trusted_data = trusted
              pal.with_catalog_compiler(**interpolations) do |compiler|
                Bolt::Result.for_lookup(target, key, compiler.call_function('lookup', key))
              rescue StandardError => e
                Bolt::Result.from_exception(target, e)
              end
            rescue Puppet::Error => e
              raise PALError.from_error(e)
            end
          end
        end
      end
      Bolt::ResultSet.new(results)
    end
def lookup ( key , targets , inventory , executor , plan_vars : { } ) in_plan_compiler ( executor , inventory , nil ) do | compiler | compiler . call_function ( 'apply_prep' , targets ) end overrides = { bolt_inventory : inventory , bolt_project : @project } results = targets . map do | target | node = Puppet :: Node . from_data_hash ( 'name' => target . name , 'parameters' => { 'clientcert' => target . name } ) trusted = Puppet :: Context :: TrustedInformation . local ( node ) . to_h env_conf = { modulepath : @modulepath . full_modulepath , facts : target . facts } interpolations = { variables : plan_vars , target_variables : target . vars } with_puppet_settings do Puppet :: Pal . in_tmp_environment ( target . name , ** env_conf ) do | pal | Puppet . override ( overrides ) do Puppet . lookup ( :pal_current_node ) . trusted_data = trusted pal . with_catalog_compiler ( ** interpolations ) do | compiler | Bolt :: Result . for_lookup ( target , key , compiler . call_function ( 'lookup' , key ) ) rescue StandardError => e Bolt :: Result . from_exception ( target , e ) end rescue Puppet :: Error => e raise PALError . from_error ( e ) end end end end Bolt :: ResultSet . new ( results ) end
PALError is used to convert errors from executing puppet code into
Bolt::Errors
PALError is used to convert errors from executing puppet code into Bolt :: Errors
# Install the puppet-agent package and collect facts. Facts are # automatically added to the targets. # Do a lookup with a catalog compiler, which uses the 'hierarchy' key in # Hiera config. # Separate environment configuration from interpolation data the same # way we do when compiling Puppet catalogs.
key
<not_specific>
targets
<not_specific>
inventory
<not_specific>
executor
<not_specific>
plan_vars
<not_specific>