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