lib/puppet/configurer.rb
# The code that actually runs the catalog.
# This just passes any options on to the catalog,
# which accepts :tags and :ignoreschedules.
The code that actually runs the catalog.
This just passes any options on to the catalog,
which accepts :tags and :ignoreschedules.
The code that actually runs the catalog . This just passes any options on to the catalog which accepts : tags and : ignoreschedules .
def run(options = {})
    options[:report] ||= Puppet::Transaction::Report.new("apply")
    report = options[:report]
    init_storage
    Puppet::Util::Log.newdestination(report)
    begin
      unless Puppet[:node_name_fact].empty?
        fact_options = get_facts(options)
      end
      begin
        if node = Puppet::Node.indirection.find(Puppet[:node_name_value],
            :environment => @environment, :ignore_cache => true)
          if node.environment.to_s != @environment
            Puppet.warning "Local environment: \"#{@environment}\" doesn't match server specified node environment \"#{node.environment}\", switching agent to \"#{node.environment}\"."
            @environment = node.environment.to_s
            fact_options = nil
          end
        end
      rescue Puppet::Error, Net::HTTPError => detail
        Puppet.warning("Unable to fetch my node definition, but the agent run will continue:")
        Puppet.warning(detail)
      end
      fact_options = get_facts(options) unless fact_options
      unless catalog = prepare_and_retrieve_catalog(options, fact_options)
        return nil
      end
      tries = 0
      while catalog.environment and not catalog.environment.empty? and catalog.environment != @environment
        if tries > 3
          raise Puppet::Error, "Catalog environment didn't stabilize after #{tries} fetches, aborting run"
        end
        Puppet.warning "Local environment: \"#{@environment}\" doesn't match server specified environment \"#{catalog.environment}\", restarting agent run with environment \"#{catalog.environment}\""
        @environment = catalog.environment
        return nil unless catalog = prepare_and_retrieve_catalog(options, fact_options)
        tries += 1
      end
      execute_prerun_command or return nil
      apply_catalog(catalog, options)
      report.exit_status
    rescue => detail
      Puppet.log_exception(detail, "Failed to apply catalog: #{detail}")
      return nil
    ensure
      execute_postrun_command or return nil
    end
  ensure
    Thread.current[:env_module_directories] = nil
    Puppet::Util::Log.close(report)
    send_report(report)
  end
def run ( options = { } ) options [ :report ] ||= Puppet :: Transaction :: Report . new ( "apply" ) report = options [ :report ] init_storage Puppet :: Util :: Log . newdestination ( report ) begin unless Puppet [ :node_name_fact ] . empty? fact_options = get_facts ( options ) end begin if node = Puppet :: Node . indirection . find ( Puppet [ :node_name_value ] , :environment => @environment , :ignore_cache => true ) if node . environment . to_s != @environment Puppet . warning "Local environment: \"#{@environment}\" doesn't match server specified node environment \"#{node.environment}\", switching agent to \"#{node.environment}\"." @environment = node . environment . to_s fact_options = nil end end rescue Puppet :: Error , Net :: HTTPError => detail Puppet . warning ( "Unable to fetch my node definition, but the agent run will continue:" ) Puppet . warning ( detail ) end fact_options = get_facts ( options ) unless fact_options unless catalog = prepare_and_retrieve_catalog ( options , fact_options ) return nil end tries = 0 while catalog . environment and not catalog . environment . empty? and catalog . environment != @environment if tries > 3 raise Puppet :: Error , "Catalog environment didn't stabilize after #{tries} fetches, aborting run" end Puppet . warning "Local environment: \"#{@environment}\" doesn't match server specified environment \"#{catalog.environment}\", restarting agent run with environment \"#{catalog.environment}\"" @environment = catalog . environment return nil unless catalog = prepare_and_retrieve_catalog ( options , fact_options ) tries += 1 end execute_prerun_command or return nil apply_catalog ( catalog , options ) report . exit_status rescue => detail Puppet . log_exception ( detail , "Failed to apply catalog: #{detail}" ) return nil ensure execute_postrun_command or return nil end ensure Thread . current [ :env_module_directories ] = nil Puppet :: Util :: Log . close ( report ) send_report ( report ) end
The code that actually runs the catalog.
The code that actually runs the catalog .
# Here we set the local environment based on what we get from the # catalog. Since a change in environment means a change in facts, and # facts may be used to determine which catalog we get, we need to # rerun the process if the environment is changed. # Between Puppet runs we need to forget the cached values.  This lets us # pick up on new functions installed by gems or new modules being added # without the daemon being restarted.
options
<not_specific>