613: def use(*sections)
614: sections = sections.collect { |s| s.to_sym }
615: @sync.synchronize do
616: sections = sections.reject { |s| @used.include?(s) }
617:
618: return if sections.empty?
619:
620: begin
621: catalog = to_catalog(*sections).to_ral
622: rescue => detail
623: puts detail.backtrace if Puppet[:trace]
624: Puppet.err "Could not create resources for managing Puppet's files and directories in sections #{sections.inspect}: #{detail}"
625:
626:
627:
628: return
629: end
630:
631: catalog.host_config = false
632: catalog.apply do |transaction|
633: if transaction.any_failed?
634: report = transaction.report
635: failures = report.logs.find_all { |log| log.level == :err }
636: raise "Got #{failures.length} failure(s) while initializing: #{failures.collect { |l| l.to_s }.join("; ")}"
637: end
638: end
639:
640: sections.each { |s| @used << s }
641: @used.uniq!
642: end
643: end